From ce1b9a7dafd5120c97271e302c30aa360c86194b Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 6 Jul 2017 11:31:09 +0100 Subject: [PATCH] swift,hubic: fix paged directory listings This was caused by rclone adjusting the object names. If the last object in the listing page happened to be a directory, rclone would remove the / which caused the next page to start in the wrong place. --- swift/swift.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/swift/swift.go b/swift/swift.go index f8ab4563f..770c81d25 100644 --- a/swift/swift.go +++ b/swift/swift.go @@ -295,10 +295,7 @@ func (f *Fs) listContainerRoot(container, root string, dir string, recurse bool, object := &objects[i] isDirectory := false if !recurse { - if strings.HasSuffix(object.Name, "/") { - isDirectory = true - object.Name = object.Name[:len(object.Name)-1] - } + isDirectory = strings.HasSuffix(object.Name, "/") } if !strings.HasPrefix(object.Name, root) { fs.Logf(f, "Odd name received %q", object.Name) @@ -321,6 +318,7 @@ type addEntryFn func(fs.DirEntry) error func (f *Fs) list(dir string, recurse bool, fn addEntryFn) error { return f.listContainerRoot(f.container, f.root, dir, recurse, func(remote string, object *swift.Object, isDirectory bool) (err error) { if isDirectory { + remote = strings.TrimRight(remote, "/") d := fs.NewDir(remote, time.Time{}).SetSize(object.Bytes) err = fn(d) } else {