MCPcopy
hub / github.com/kopia/kopia / LoadSnapshots

Function LoadSnapshots

snapshot/manager.go:152–187  ·  view source on GitHub ↗

LoadSnapshots efficiently loads and parses a given list of snapshot IDs.

(ctx context.Context, rep repo.Repository, manifestIDs []manifest.ID)

Source from the content-addressed store, hash-verified

150
151// LoadSnapshots efficiently loads and parses a given list of snapshot IDs.
152func LoadSnapshots(ctx context.Context, rep repo.Repository, manifestIDs []manifest.ID) ([]*Manifest, error) {
153 result := make([]*Manifest, len(manifestIDs))
154 sem := make(chan bool, loadSnapshotsConcurrency)
155
156 for i, n := range manifestIDs {
157 sem <- true
158
159 go func(i int, n manifest.ID) {
160 defer func() { <-sem }()
161
162 m, err := LoadSnapshot(ctx, rep, n)
163 if err != nil {
164 log(ctx).Errorf("unable to parse snapshot manifest %v: %v", n, err)
165 return
166 }
167
168 result[i] = m
169 }(i, n)
170 }
171
172 for range cap(sem) {
173 sem <- true
174 }
175
176 close(sem)
177
178 successful := result[:0]
179
180 for _, m := range result {
181 if m != nil {
182 successful = append(successful, m)
183 }
184 }
185
186 return successful, nil
187}
188
189// ListSnapshotManifests returns the list of snapshot manifests for a given source or all sources if nil.
190func ListSnapshotManifests(ctx context.Context, rep repo.Repository, src *SourceInfo, tags map[string]string) ([]manifest.ID, error) {

Callers 13

snapshotDeleteSourcesMethod · 0.92
loadSourceManifestsMethod · 0.92
loadSnapIDManifestsMethod · 0.92
migrateSingleSourceMethod · 0.92
runMethod · 0.92
tryToConvertPathToIDMethod · 0.92
handleListSnapshotsFunction · 0.92
handleDeleteSnapshotsFunction · 0.92
verifyLoadSnapshotsFunction · 0.92
findInUseContentIDsFunction · 0.92
ListSnapshotsFunction · 0.85

Calls 2

LoadSnapshotFunction · 0.85
ErrorfMethod · 0.80

Tested by 1

verifyLoadSnapshotsFunction · 0.74