From 1b5684e6f8fa1086272e79d41375e6e2167acf35 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 18 Jul 2020 10:47:15 -0700 Subject: [PATCH] Make sure errors are handled --- server/filesystem.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/filesystem.go b/server/filesystem.go index 0e8c8b0..0daea8a 100644 --- a/server/filesystem.go +++ b/server/filesystem.go @@ -224,6 +224,10 @@ func (fs *Filesystem) getCachedDiskUsage() (int64, error) { func (fs *Filesystem) DirectorySize(dir string) (int64, error) { var size int64 err := fs.Walk(dir, func(_ string, f os.FileInfo, err error) error { + if err != nil { + return err + } + if !f.IsDir() { atomic.AddInt64(&size, f.Size()) } @@ -663,6 +667,10 @@ func (fs *Filesystem) GetIncludedFiles(dir string, ignored []string) (*backup.In inc := new(backup.IncludedFiles) if err := fs.Walk(cleaned, func(p string, f os.FileInfo, err error) error { + if err != nil { + return err + } + // Avoid unnecessary parsing if there are no ignored files, nothing will match anyways // so no reason to call the function. if len(ignored) == 0 || !i.MatchesPath(strings.TrimPrefix(p, fs.Path()+"/")) { @@ -716,6 +724,10 @@ func (fs *Filesystem) CompressFiles(dir string, paths []string) (os.FileInfo, er if f.IsDir() { err := fs.Walk(p, func(s string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if !info.IsDir() { inc.Push(&info, s) }