FilesystemEntryFromIDWithPath returns a filesystem entry for the provided object ID, which can be a snapshot manifest ID or an object ID with path. If multiple snapshots match and they don't agree on root object attributes and consistentAttributes==true the function fails, otherwise it returns the l
(ctx context.Context, rep repo.Repository, rootID string, consistentAttributes bool)
| 144 | // If multiple snapshots match and they don't agree on root object attributes and consistentAttributes==true |
| 145 | // the function fails, otherwise it returns the latest of the snapshots. |
| 146 | func FilesystemEntryFromIDWithPath(ctx context.Context, rep repo.Repository, rootID string, consistentAttributes bool) (fs.Entry, error) { |
| 147 | pathElements := strings.Split(filepath.ToSlash(rootID), "/") |
| 148 | |
| 149 | if len(pathElements) > 1 { |
| 150 | // if a path is provided, consistentAttributes is meaningless since descending into nested path is |
| 151 | // always unambiguous because parent always has full attributes. |
| 152 | consistentAttributes = false |
| 153 | } |
| 154 | |
| 155 | var startingEntry fs.Entry |
| 156 | |
| 157 | man, err := FindSnapshotByRootObjectIDOrManifestID(ctx, rep, pathElements[0], consistentAttributes) |
| 158 | if err != nil { |
| 159 | return nil, err |
| 160 | } |
| 161 | |
| 162 | if man != nil { |
| 163 | // ID was unambiguously resolved to a snapshot, which means we have data about the root directory itself. |
| 164 | startingEntry, err = SnapshotRoot(rep, man) |
| 165 | if err != nil { |
| 166 | return nil, err |
| 167 | } |
| 168 | } else { |
| 169 | oid, err := object.ParseID(pathElements[0]) |
| 170 | if err != nil { |
| 171 | return nil, errors.Wrapf(err, "can't parse object ID %v", rootID) |
| 172 | } |
| 173 | |
| 174 | startingEntry = AutoDetectEntryFromObjectID(ctx, rep, oid, "") |
| 175 | } |
| 176 | |
| 177 | return GetNestedEntry(ctx, startingEntry, pathElements[1:]) |
| 178 | } |
| 179 | |
| 180 | // FilesystemDirectoryFromIDWithPath returns a filesystem directory entry for the provided object ID, which |
| 181 | // can be a snapshot manifest ID or an object ID with path. |
no test coverage detected