MCPcopy Index your code
hub / github.com/kopia/kopia / makeVerifyWalkerFunc

Method makeVerifyWalkerFunc

cli/command_snapshot_verify.go:101–174  ·  view source on GitHub ↗
(ctx context.Context, rep repo.Repository, v *snapshotfs.Verifier)

Source from the content-addressed store, hash-verified

99}
100
101func (c *commandSnapshotVerify) makeVerifyWalkerFunc(ctx context.Context, rep repo.Repository, v *snapshotfs.Verifier) func(tw *snapshotfs.TreeWalker) error {
102 return func(tw *snapshotfs.TreeWalker) error {
103 manifests, err := c.loadSourceManifests(ctx, rep)
104 if err != nil {
105 return err
106 }
107
108 snapIDManifests, err := c.loadSnapIDManifests(ctx, rep)
109 if err != nil {
110 return err
111 }
112
113 manifests = append(manifests, snapIDManifests...)
114
115 type twEntry struct {
116 root fs.Entry
117 rootPath string
118 }
119
120 var treeWalkerEntries []twEntry
121
122 for _, man := range manifests {
123 rootPath := fmt.Sprintf("%v@%v", man.Source, formatTimestamp(man.StartTime.ToTime()))
124
125 if man.RootEntry == nil {
126 continue
127 }
128
129 root, err := snapshotfs.SnapshotRoot(rep, man)
130 if err != nil {
131 return errors.Wrapf(err, "unable to get snapshot root: %q", rootPath)
132 }
133
134 treeWalkerEntries = append(treeWalkerEntries, twEntry{
135 root: root,
136 rootPath: rootPath,
137 })
138
139 if err := addExpectedWorkFromDirSummaryToVerifier(ctx, v, root); err != nil {
140 return errors.Wrapf(err, "unable to set stat totals from summary")
141 }
142 }
143
144 for _, twEntry := range treeWalkerEntries {
145 // ignore error now, return aggregate error at a higher level.
146 //nolint:errcheck
147 tw.Process(ctx, twEntry.root, twEntry.rootPath)
148 }
149
150 for _, oidStr := range c.verifyCommandDirObjectIDs {
151 oid, err := snapshotfs.ParseObjectIDWithPath(ctx, rep, oidStr)
152 if err != nil {
153 return errors.Wrapf(err, "unable to parse: %q", oidStr)
154 }
155
156 // ignore error now, return aggregate error at a higher level.
157 //nolint:errcheck
158 tw.Process(ctx, snapshotfs.DirectoryEntry(rep, oid, nil), oidStr)

Callers 1

runMethod · 0.95

Calls 10

loadSourceManifestsMethod · 0.95
loadSnapIDManifestsMethod · 0.95
SnapshotRootFunction · 0.92
ParseObjectIDWithPathFunction · 0.92
DirectoryEntryFunction · 0.92
formatTimestampFunction · 0.85
ToTimeMethod · 0.80
ProcessMethod · 0.45

Tested by

no test coverage detected