MCPcopy
hub / github.com/kopia/kopia / ListSources

Function ListSources

snapshot/manager.go:39–58  ·  view source on GitHub ↗

ListSources lists all snapshot sources in a given repository.

(ctx context.Context, rep repo.Repository)

Source from the content-addressed store, hash-verified

37
38// ListSources lists all snapshot sources in a given repository.
39func ListSources(ctx context.Context, rep repo.Repository) ([]SourceInfo, error) {
40 items, err := rep.FindManifests(ctx, map[string]string{
41 typeKey: ManifestType,
42 })
43 if err != nil {
44 return nil, errors.Wrap(err, "unable to find manifest entries")
45 }
46
47 uniq := map[SourceInfo]bool{}
48 for _, it := range items {
49 uniq[sourceInfoFromLabels(it.Labels)] = true
50 }
51
52 var infos []SourceInfo
53 for k := range uniq {
54 infos = append(infos, k)
55 }
56
57 return infos, nil
58}
59
60func sourceInfoFromLabels(labels map[string]string) SourceInfo {
61 return SourceInfo{Host: labels[HostnameLabel], UserName: labels[UsernameLabel], Path: labels[PathLabel]}

Callers 7

getLocalBackupPathsFunction · 0.92
getSourcesToMigrateMethod · 0.92
syncSourcesLockedMethod · 0.92
verifySourcesFunction · 0.92
IterateMethod · 0.92
IterateMethod · 0.92

Calls 2

sourceInfoFromLabelsFunction · 0.85
FindManifestsMethod · 0.65

Tested by 1

verifySourcesFunction · 0.74