MCPcopy
hub / github.com/kopia/kopia / ParseObjectIDWithPath

Function ParseObjectIDWithPath

snapshot/snapshotfs/objref.go:20–33  ·  view source on GitHub ↗

ParseObjectIDWithPath interprets the given ID string (which could be an object ID optionally followed by nested path specification) and returns corresponding object.ID.

(ctx context.Context, rep repo.Repository, objectIDWithPath string)

Source from the content-addressed store, hash-verified

18// ParseObjectIDWithPath interprets the given ID string (which could be an object ID optionally followed by
19// nested path specification) and returns corresponding object.ID.
20func ParseObjectIDWithPath(ctx context.Context, rep repo.Repository, objectIDWithPath string) (object.ID, error) {
21 parts := strings.Split(objectIDWithPath, "/")
22
23 oid, err := object.ParseID(parts[0])
24 if err != nil {
25 return object.EmptyID, errors.Wrapf(err, "can't parse object ID %v", objectIDWithPath)
26 }
27
28 if len(parts) == 1 {
29 return oid, nil
30 }
31
32 return parseNestedObjectID(ctx, AutoDetectEntryFromObjectID(ctx, rep, oid, ""), parts[1:])
33}
34
35// GetNestedEntry returns nested entry with a given name path.
36func GetNestedEntry(ctx context.Context, startingDir fs.Entry, pathElements []string) (fs.Entry, error) {

Callers 4

runMethod · 0.92
makeVerifyWalkerFuncMethod · 0.92
runMethod · 0.92
SnapshotRestoreMethod · 0.92

Calls 3

ParseIDFunction · 0.92
parseNestedObjectIDFunction · 0.85

Tested by

no test coverage detected