From 52247e9a9f94bd23297e97703ebe8cc13c0af265 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 19 Aug 2020 18:02:21 +0100 Subject: [PATCH] local: return fs.ErrorDirNot found from About and Purge Before this a stat error was returned which wasn't very helpful. --- backend/local/about_unix.go | 4 ++++ backend/local/local.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/backend/local/about_unix.go b/backend/local/about_unix.go index f856a7964..3c31d17a1 100644 --- a/backend/local/about_unix.go +++ b/backend/local/about_unix.go @@ -4,6 +4,7 @@ package local import ( "context" + "os" "syscall" "github.com/pkg/errors" @@ -15,6 +16,9 @@ func (f *Fs) About(ctx context.Context) (*fs.Usage, error) { var s syscall.Statfs_t err := syscall.Statfs(f.root, &s) if err != nil { + if os.IsNotExist(err) { + return nil, fs.ErrorDirNotFound + } return nil, errors.Wrap(err, "failed to read disk usage") } bs := int64(s.Bsize) // nolint: unconvert diff --git a/backend/local/local.go b/backend/local/local.go index 90aad3c96..887c66725 100644 --- a/backend/local/local.go +++ b/backend/local/local.go @@ -625,6 +625,10 @@ func (f *Fs) Purge(ctx context.Context, dir string) error { dir = f.localPath(dir) fi, err := f.lstat(dir) if err != nil { + // already purged + if os.IsNotExist(err) { + return fs.ErrorDirNotFound + } return err } if !fi.Mode().IsDir() {