1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-25 01:06:39 +00:00

Catch errors when walking cache directories

This commit is contained in:
Johannes Hertenstein 2018-10-08 15:47:34 +02:00
parent ed651df19b
commit 277cba4b32

View file

@ -152,10 +152,15 @@ func runCache(opts CacheOptions, gopts GlobalOptions, args []string) error {
func dirSize(path string) (int64, error) { func dirSize(path string) (int64, error) {
var size int64 var size int64
err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error { err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
if err != nil || info == nil {
return err
}
if !info.IsDir() { if !info.IsDir() {
size += info.Size() size += info.Size()
} }
return err
return nil
}) })
return size, err return size, err
} }