mirror of
https://github.com/rclone/rclone.git
synced 2025-02-16 18:41:54 +01:00
google cloud storage: fix ListDir on subdirectory
This commit is contained in:
parent
457ef2c190
commit
cc679aa714
@ -255,10 +255,8 @@ func (f *FsStorage) list(directories bool, fn func(string, *storage.Object)) {
|
|||||||
fs.Log(f, "Couldn't read bucket %q: %s", f.bucket, err)
|
fs.Log(f, "Couldn't read bucket %q: %s", f.bucket, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !directories {
|
||||||
for _, object := range objects.Items {
|
for _, object := range objects.Items {
|
||||||
if directories && !strings.HasSuffix(object.Name, "/") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if !strings.HasPrefix(object.Name, f.root) {
|
if !strings.HasPrefix(object.Name, f.root) {
|
||||||
fs.Log(f, "Odd name received %q", object.Name)
|
fs.Log(f, "Odd name received %q", object.Name)
|
||||||
continue
|
continue
|
||||||
@ -266,6 +264,15 @@ func (f *FsStorage) list(directories bool, fn func(string, *storage.Object)) {
|
|||||||
remote := object.Name[rootLength:]
|
remote := object.Name[rootLength:]
|
||||||
fn(remote, object)
|
fn(remote, object)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
var object storage.Object
|
||||||
|
for _, prefix := range objects.Prefixes {
|
||||||
|
if !strings.HasSuffix(prefix, "/") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fn(prefix[:len(prefix)-1], &object)
|
||||||
|
}
|
||||||
|
}
|
||||||
if objects.NextPageToken == "" {
|
if objects.NextPageToken == "" {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user