Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

Fix remaining places in listing where we were logging errors not returning them

Nick Craig-Woodc6a79ff72d85
diff --git a/dropbox/dropbox.go b/dropbox/dropbox.go
index cb2fa9b96..8ebbe24ce 100644
--- a/dropbox/dropbox.go
+++ b/dropbox/dropbox.go
@@ -271,8 +271,8 @@ func (f *Fs) list(out fs.ListOpts, dir string) {
return
}
if deltaPage.Reset && cursor != "" {
- fs.ErrorLog(f, "Unexpected reset during listing - try again")
- fs.Stats.Error()
+ err = errors.New("Unexpected reset during listing")
+ out.SetError(err)
break
}
fs.Debug(f, "%d delta entries received", len(deltaPage.Entries))
@@ -283,8 +283,7 @@ func (f *Fs) list(out fs.ListOpts, dir string) {
// This notifies of a deleted object
} else {
if len(entry.Path) <= 1 || entry.Path[0] != '/' {
- fs.Stats.Error()
- fs.ErrorLog(f, "dropbox API inconsistency: a path should always start with a slash and be at least 2 characters: %s", entry.Path)
+ fs.Log(f, "dropbox API inconsistency: a path should always start with a slash and be at least 2 characters: %s", entry.Path)
continue
}
diff --git a/dropbox/nametree.go b/dropbox/nametree.go
index 3edace20e..4c0934590 100644
--- a/dropbox/nametree.go
+++ b/dropbox/nametree.go
@@ -9,6 +9,8 @@ import (
"github.com/stacktic/dropbox"
)
+// FIXME Get rid of Stats.Error() counting and return errors
+
type nameTreeNode struct {
// Map from lowercase directory name to tree node
Directories map[string]*nameTreeNode
diff --git a/local/local.go b/local/local.go
index 04274bcf8..cac0394a6 100644
--- a/local/local.go
+++ b/local/local.go
@@ -16,6 +16,7 @@ import (
"unicode/utf8"
"github.com/ncw/rclone/fs"
+ "github.com/pkg/errors"
)
// Register with Fs
@@ -150,17 +151,13 @@ type listArgs struct {
func (f *Fs) list(out fs.ListOpts, remote string, dirpath string, level int) (subdirs []listArgs) {
fd, err := os.Open(dirpath)
if err != nil {
- out.SetError(err)
- fs.Stats.Error()
- fs.ErrorLog(f, "Failed to open directory: %s: %s", dirpath, err)
+ out.SetError(errors.Wrapf(err, "failed to open directory %q", dirpath))
return nil
}
defer func() {
err := fd.Close()
if err != nil {
- out.SetError(err)
- fs.Stats.Error()
- fs.ErrorLog(f, "Failed to close directory: %s: %s", dirpath, err)
+ out.SetError(errors.Wrapf(err, "failed to close directory %q:", dirpath))
}
}()
@@ -170,9 +167,8 @@ func (f *Fs) list(out fs.ListOpts, remote string, dirpath string, level int) (su
break
}
if err != nil {
- out.SetError(err)
- fs.Stats.Error()
- fs.ErrorLog(f, "Failed to read directory: %s: %s", dirpath, err)
+ out.SetError(errors.Wrapf(err, "failed to read directory %q", dirpath))
+
return nil
}
@@ -494,9 +490,7 @@ func (o *Object) Hash(r fs.HashType) (string, error) {
oldsize := o.info.Size()
err := o.lstat()
if err != nil {
- fs.Stats.Error()
- fs.ErrorLog(o, "Failed to stat: %s", err)
- return "", err
+ return "", errors.Wrap(err, "Hash failed to stat")
}
if !o.info.ModTime().Equal(oldtime) || oldsize != o.info.Size() {
@@ -507,21 +501,15 @@ func (o *Object) Hash(r fs.HashType) (string, error) {
o.hashes = make(map[fs.HashType]string)
in, err := os.Open(o.path)
if err != nil {
- fs.Stats.Error()
- fs.ErrorLog(o, "Failed to open: %s", err)
- return "", err
+ return "", errors.Wrap(err, "Hash failed to open")
}
o.hashes, err = fs.HashStream(in)
closeErr := in.Close()
if err != nil {
- fs.Stats.Error()
- fs.ErrorLog(o, "Failed to read: %s", err)
- return "", err
+ return "", errors.Wrap(err, "Hash failed to read")
}
if closeErr != nil {
- fs.Stats.Error()
- fs.ErrorLog(o, "Failed to close: %s", closeErr)
- return "", closeErr
+ return "", errors.Wrap(closeErr, "Hash failed to close")
}
}
return o.hashes[r], nil
diff --git a/onedrive/onedrive.go b/onedrive/onedrive.go
index f4ceed2b0..fcd482899 100644
--- a/onedrive/onedrive.go
+++ b/onedrive/onedrive.go
@@ -18,6 +18,7 @@ import (
"github.com/ncw/rclone/onedrive/api"
"github.com/ncw/rclone/pacer"
"github.com/ncw/rclone/rest"
+ "github.com/pkg/errors"
"github.com/spf13/pflag"
"golang.org/x/oauth2"
)
@@ -331,9 +332,7 @@ OUTER:
return shouldRetry(resp, err)
})
if err != nil {
- fs.Stats.Error()
- fs.ErrorLog(f, "Couldn't list files: %v", err)
- break
+ return found, errors.Wrap(err, "couldn't list files")
}
if len(result.Value) == 0 {
break