forked from TrueCloudLab/rclone
Fix remaining places in listing where we were logging errors not returning them
This commit is contained in:
parent
b6f1391da3
commit
c6a79ff72d
4 changed files with 16 additions and 28 deletions
|
@ -271,8 +271,8 @@ func (f *Fs) list(out fs.ListOpts, dir string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if deltaPage.Reset && cursor != "" {
|
if deltaPage.Reset && cursor != "" {
|
||||||
fs.ErrorLog(f, "Unexpected reset during listing - try again")
|
err = errors.New("Unexpected reset during listing")
|
||||||
fs.Stats.Error()
|
out.SetError(err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
fs.Debug(f, "%d delta entries received", len(deltaPage.Entries))
|
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
|
// This notifies of a deleted object
|
||||||
} else {
|
} else {
|
||||||
if len(entry.Path) <= 1 || entry.Path[0] != '/' {
|
if len(entry.Path) <= 1 || entry.Path[0] != '/' {
|
||||||
fs.Stats.Error()
|
fs.Log(f, "dropbox API inconsistency: a path should always start with a slash and be at least 2 characters: %s", entry.Path)
|
||||||
fs.ErrorLog(f, "dropbox API inconsistency: a path should always start with a slash and be at least 2 characters: %s", entry.Path)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ import (
|
||||||
"github.com/stacktic/dropbox"
|
"github.com/stacktic/dropbox"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// FIXME Get rid of Stats.Error() counting and return errors
|
||||||
|
|
||||||
type nameTreeNode struct {
|
type nameTreeNode struct {
|
||||||
// Map from lowercase directory name to tree node
|
// Map from lowercase directory name to tree node
|
||||||
Directories map[string]*nameTreeNode
|
Directories map[string]*nameTreeNode
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/ncw/rclone/fs"
|
"github.com/ncw/rclone/fs"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register with Fs
|
// 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) {
|
func (f *Fs) list(out fs.ListOpts, remote string, dirpath string, level int) (subdirs []listArgs) {
|
||||||
fd, err := os.Open(dirpath)
|
fd, err := os.Open(dirpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
out.SetError(err)
|
out.SetError(errors.Wrapf(err, "failed to open directory %q", dirpath))
|
||||||
fs.Stats.Error()
|
|
||||||
fs.ErrorLog(f, "Failed to open directory: %s: %s", dirpath, err)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
err := fd.Close()
|
err := fd.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
out.SetError(err)
|
out.SetError(errors.Wrapf(err, "failed to close directory %q:", dirpath))
|
||||||
fs.Stats.Error()
|
|
||||||
fs.ErrorLog(f, "Failed to close directory: %s: %s", dirpath, err)
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -170,9 +167,8 @@ func (f *Fs) list(out fs.ListOpts, remote string, dirpath string, level int) (su
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
out.SetError(err)
|
out.SetError(errors.Wrapf(err, "failed to read directory %q", dirpath))
|
||||||
fs.Stats.Error()
|
|
||||||
fs.ErrorLog(f, "Failed to read directory: %s: %s", dirpath, err)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,9 +490,7 @@ func (o *Object) Hash(r fs.HashType) (string, error) {
|
||||||
oldsize := o.info.Size()
|
oldsize := o.info.Size()
|
||||||
err := o.lstat()
|
err := o.lstat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Stats.Error()
|
return "", errors.Wrap(err, "Hash failed to stat")
|
||||||
fs.ErrorLog(o, "Failed to stat: %s", err)
|
|
||||||
return "", err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !o.info.ModTime().Equal(oldtime) || oldsize != o.info.Size() {
|
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)
|
o.hashes = make(map[fs.HashType]string)
|
||||||
in, err := os.Open(o.path)
|
in, err := os.Open(o.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Stats.Error()
|
return "", errors.Wrap(err, "Hash failed to open")
|
||||||
fs.ErrorLog(o, "Failed to open: %s", err)
|
|
||||||
return "", err
|
|
||||||
}
|
}
|
||||||
o.hashes, err = fs.HashStream(in)
|
o.hashes, err = fs.HashStream(in)
|
||||||
closeErr := in.Close()
|
closeErr := in.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Stats.Error()
|
return "", errors.Wrap(err, "Hash failed to read")
|
||||||
fs.ErrorLog(o, "Failed to read: %s", err)
|
|
||||||
return "", err
|
|
||||||
}
|
}
|
||||||
if closeErr != nil {
|
if closeErr != nil {
|
||||||
fs.Stats.Error()
|
return "", errors.Wrap(closeErr, "Hash failed to close")
|
||||||
fs.ErrorLog(o, "Failed to close: %s", closeErr)
|
|
||||||
return "", closeErr
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return o.hashes[r], nil
|
return o.hashes[r], nil
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"github.com/ncw/rclone/onedrive/api"
|
"github.com/ncw/rclone/onedrive/api"
|
||||||
"github.com/ncw/rclone/pacer"
|
"github.com/ncw/rclone/pacer"
|
||||||
"github.com/ncw/rclone/rest"
|
"github.com/ncw/rclone/rest"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
)
|
)
|
||||||
|
@ -331,9 +332,7 @@ OUTER:
|
||||||
return shouldRetry(resp, err)
|
return shouldRetry(resp, err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Stats.Error()
|
return found, errors.Wrap(err, "couldn't list files")
|
||||||
fs.ErrorLog(f, "Couldn't list files: %v", err)
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
if len(result.Value) == 0 {
|
if len(result.Value) == 0 {
|
||||||
break
|
break
|
||||||
|
|
Loading…
Add table
Reference in a new issue