1
mirror of https://github.com/rclone/rclone synced 2024-12-24 15:43:45 +01:00

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

This commit is contained in:
Nick Craig-Wood 2016-05-30 19:49:21 +01:00
parent b6f1391da3
commit c6a79ff72d
4 changed files with 16 additions and 28 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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