"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
dropbox: match shared-folder and received-file names case-insensitively - fixes #9706
phatlcb549554c31b5
diff --git a/backend/dropbox/dropbox.go b/backend/dropbox/dropbox.goindex fa1d125bf..8ee55eb1d 100644--- a/backend/dropbox/dropbox.go+++ b/backend/dropbox/dropbox.go@@ -957,7 +957,7 @@ func sharedFolderName(root string) string {func (f *Fs) findSharedFolder(ctx context.Context, name string) (id string, err error) {errFoundFile := errors.New("found file")err = f.listSharedFolders(ctx, func(entry fs.DirEntry) error {- if entry.(*fs.Dir).Remote() == name {+ if strings.EqualFold(entry.(*fs.Dir).Remote(), name) {id = entry.(*fs.Dir).ID()return errFoundFile}@@ -1039,7 +1039,7 @@ func (f *Fs) listReceivedFiles(ctx context.Context, callback func(fs.DirEntry) efunc (f *Fs) findSharedFile(ctx context.Context, name string) (o *Object, err error) {errFoundFile := errors.New("found file")err = f.listReceivedFiles(ctx, func(entry fs.DirEntry) error {- if entry.(*Object).remote == name {+ if strings.EqualFold(entry.(*Object).remote, name) {o = entry.(*Object)return errFoundFile}diff --git a/backend/dropbox/dropbox_internal_test.go b/backend/dropbox/dropbox_internal_test.goindex e96228a4d..78a701f69 100644--- a/backend/dropbox/dropbox_internal_test.go+++ b/backend/dropbox/dropbox_internal_test.go@@ -490,3 +490,48 @@ func TestFindSharedFileResolvesDecodedName(t *testing.T) {require.NoError(t, err)assert.Equal(t, encodedName, o.remote)}++// sharedFoldersHandler serves a single shared folder from list_folders.+func sharedFoldersHandler(name, id string) http.HandlerFunc {+ return func(w http.ResponseWriter, r *http.Request) {+ if !strings.Contains(r.URL.Path, "list_folders") {+ http.NotFound(w, r)+ return+ }+ resp := sharing.ListFoldersResult{+ Entries: []*sharing.SharedFolderMetadata{{Name: name, SharedFolderId: id}},+ }+ w.Header().Set("Content-Type", "application/json")+ _ = json.NewEncoder(w).Encode(resp)+ }+}++// The Dropbox backend advertises CaseInsensitive: true, so a shared folder+// lookup must match regardless of the case of the requested name.+func TestInternalFindSharedFolderCaseInsensitive(t *testing.T) {+ f := newSharingTestFs(t, sharedFoldersHandler("TestFolder", "folder-id"))++ for _, name := range []string{"TestFolder", "testfolder", "TESTFOLDER"} {+ id, err := f.findSharedFolder(context.Background(), name)+ require.NoError(t, err, name)+ assert.Equal(t, "folder-id", id, name)+ }++ _, err := f.findSharedFolder(context.Background(), "no-such-folder")+ assert.ErrorIs(t, err, fs.ErrorDirNotFound)+}++// The Dropbox backend advertises CaseInsensitive: true, so a received file+// lookup must match regardless of the case of the requested name.+func TestInternalFindSharedFileCaseInsensitive(t *testing.T) {+ f := newSharingTestFs(t, receivedFilesHandler(t, "TestFile.txt"))++ for _, name := range []string{"TestFile.txt", "testfile.txt", "TESTFILE.TXT"} {+ o, err := f.findSharedFile(context.Background(), name)+ require.NoError(t, err, name)+ assert.Equal(t, "TestFile.txt", o.remote, name)+ }++ _, err := f.findSharedFile(context.Background(), "no-such-file.txt")+ assert.ErrorIs(t, err, fs.ErrorObjectNotFound)+}