"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
operations: fix lsjson --stat on root directories of bucket based backends
Nick Craig-Wood54da6154c4af
diff --git a/fs/operations/lsjson.go b/fs/operations/lsjson.goindex 202895d1a..3a311d1f3 100644--- a/fs/operations/lsjson.go+++ b/fs/operations/lsjson.go@@ -264,6 +264,21 @@ func StatJSON(ctx context.Context, fsrc fs.Fs, remote string, opt *ListJSONOpt)if err != nil {return nil, err}++ // Root is always a directory. When we have a NewDirEntry+ // primitive we need to call it, but for now this will do.+ if remote == "" {+ if !lj.dirs {+ return nil, nil+ }+ // Check the root directory exists+ _, err := fsrc.List(ctx, "")+ if err != nil {+ return nil, err+ }+ return lj.entry(ctx, fs.NewDir("", time.Now()))+ }+// Could be a file or a directory hereif lj.files {// NewObject can return the sentinel errors ErrorObjectNotFound or ErrorIsDir@@ -288,14 +303,6 @@ func StatJSON(ctx context.Context, fsrc fs.Fs, remote string, opt *ListJSONOpt)}}// Must be a directory here- if remote == "" {- // Check the root directory exists- _, err := fsrc.List(ctx, "")- if err != nil {- return nil, err- }- return lj.entry(ctx, fs.NewDir("", time.Now()))- }parent := path.Dir(remote)if parent == "." || parent == "/" {parent = ""diff --git a/fs/operations/lsjson_test.go b/fs/operations/lsjson_test.goindex 257c59c03..f9e7fc53a 100644--- a/fs/operations/lsjson_test.go+++ b/fs/operations/lsjson_test.go@@ -133,7 +133,7 @@ func TestListJSON(t *testing.T) {IsDir: false,}},}, {- name: "NoModTime",+ name: "NoMimeType",opt: operations.ListJSONOpt{FilesOnly: true,NoMimeType: true,@@ -254,6 +254,24 @@ func TestStatJSON(t *testing.T) {Name: "",IsDir: true,},+ }, {+ name: "RootFilesOnly",+ remote: "",+ opt: operations.ListJSONOpt{+ FilesOnly: true,+ },+ want: nil,+ }, {+ name: "RootDirsOnly",+ remote: "",+ opt: operations.ListJSONOpt{+ DirsOnly: true,+ },+ want: &operations.ListJSONItem{+ Path: "",+ Name: "",+ IsDir: true,+ },}, {name: "Dir",remote: "sub",