local: return fs.ErrorDirNot found from About and Purge
Before this a stat error was returned which wasn't very helpful.
This commit is contained in:
parent
d2ad293fae
commit
52247e9a9f
2 changed files with 8 additions and 0 deletions
|
@ -4,6 +4,7 @@ package local
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"os"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -15,6 +16,9 @@ func (f *Fs) About(ctx context.Context) (*fs.Usage, error) {
|
||||||
var s syscall.Statfs_t
|
var s syscall.Statfs_t
|
||||||
err := syscall.Statfs(f.root, &s)
|
err := syscall.Statfs(f.root, &s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return nil, fs.ErrorDirNotFound
|
||||||
|
}
|
||||||
return nil, errors.Wrap(err, "failed to read disk usage")
|
return nil, errors.Wrap(err, "failed to read disk usage")
|
||||||
}
|
}
|
||||||
bs := int64(s.Bsize) // nolint: unconvert
|
bs := int64(s.Bsize) // nolint: unconvert
|
||||||
|
|
|
@ -625,6 +625,10 @@ func (f *Fs) Purge(ctx context.Context, dir string) error {
|
||||||
dir = f.localPath(dir)
|
dir = f.localPath(dir)
|
||||||
fi, err := f.lstat(dir)
|
fi, err := f.lstat(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// already purged
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return fs.ErrorDirNotFound
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !fi.Mode().IsDir() {
|
if !fi.Mode().IsDir() {
|
||||||
|
|
Loading…
Reference in a new issue