MCPcopy
hub / github.com/kopia/kopia / ParseID

Function ParseID

repo/object/objectid.go:164–196  ·  view source on GitHub ↗

ParseID converts the specified string into object ID.

(s string)

Source from the content-addressed store, hash-verified

162
163// ParseID converts the specified string into object ID.
164func ParseID(s string) (ID, error) {
165 var id ID
166
167 for s != "" && s[0] == 'I' {
168 id.indirection++
169
170 s = s[1:]
171 }
172
173 if s != "" && s[0] == 'Z' {
174 id.compression = true
175
176 s = s[1:]
177 }
178
179 if s != "" && s[0] == 'D' {
180 // no-op, legacy case
181 s = s[1:]
182 }
183
184 if id.indirection > 0 && id.compression {
185 return id, errors.New("malformed object ID - compression and indirection are mutually exclusive")
186 }
187
188 cid, err := index.ParseID(s)
189 if err != nil {
190 return id, errors.Wrapf(err, "malformed content ID: %q", s)
191 }
192
193 id.cid = cid
194
195 return id, nil
196}

Callers 15

tryToConvertPathToIDMethod · 0.92
mustParseObjectIDFunction · 0.92
handleObjectGetFunction · 0.92
handleMountCreateFunction · 0.92
handleMountGetFunction · 0.92
handleMountDeleteFunction · 0.92
mustParseObjectIDFunction · 0.92
mustParseIDFunction · 0.92
ParseObjectIDWithPathFunction · 0.92

Calls 1

ParseIDFunction · 0.92

Tested by 10

mustParseObjectIDFunction · 0.74
mustParseObjectIDFunction · 0.74
mustParseIDFunction · 0.74
findAllEntriesFunction · 0.74
TestParseObjectIDFunction · 0.56
mustParseIDFunction · 0.56
TestReaderFunction · 0.56