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

Function scanCacheDir

cli/command_repository_status.go:266–303  ·  view source on GitHub ↗
(dirname string)

Source from the content-addressed store, hash-verified

264}
265
266func scanCacheDir(dirname string) (fileCount int, totalFileLength int64, err error) {
267 entries, err := os.ReadDir(dirname)
268 if err != nil {
269 return 0, 0, errors.Wrap(err, "unable to read cache directory")
270 }
271
272 for _, e := range entries {
273 fi, err := e.Info()
274 if os.IsNotExist(err) {
275 // we lost the race, the file was deleted since it was listed.
276 continue
277 }
278
279 if err != nil {
280 return 0, 0, errors.Wrap(err, "unable to read file info")
281 }
282
283 if fi.IsDir() {
284 subdir := filepath.Join(dirname, fi.Name())
285
286 c, l, err2 := scanCacheDir(subdir)
287 if err2 != nil {
288 return 0, 0, err2
289 }
290
291 fileCount += c
292 totalFileLength += l
293
294 continue
295 }
296
297 fileCount++
298
299 totalFileLength += fi.Size()
300 }
301
302 return fileCount, totalFileLength, nil
303}

Callers 1

runMethod · 0.85

Calls 6

InfoMethod · 0.80
ReadDirMethod · 0.65
IsNotExistMethod · 0.65
NameMethod · 0.65
IsDirMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected