dropbox: fix shared folder mount for roots nested more than one level deep

In shared_folders mode NewFs derived the shared folder name with
path.Dir(f.root), which returns the parent path rather than the first
path component. For a root like "SharedFolder/subdir/deeper" this yielded
"SharedFolder/subdir", which findSharedFolder cannot match, so NewFs
failed with ErrorDirNotFound. Use the first path component of the root,
as the shared_folders option documents, so deeply nested roots mount.

Fixes #9705
This commit is contained in:
phatlc
2026-09-08 16:55:15 +01:00
committed by Nick Craig-Wood
parent 13084df67c
commit ac7cfcc848
2 changed files with 24 additions and 6 deletions
+9 -6
View File
@@ -634,13 +634,8 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
return f, nil // our root it empty so we probably want to list shared folders return f, nil // our root it empty so we probably want to list shared folders
} }
dir := path.Dir(f.root)
if dir == "." {
dir = f.root
}
// root is not empty so we have find the right shared folder if it exists // root is not empty so we have find the right shared folder if it exists
id, err := f.findSharedFolder(ctx, dir) id, err := f.findSharedFolder(ctx, sharedFolderName(f.root))
if err != nil { if err != nil {
// if we didn't find the specified shared folder we have to bail out here // if we didn't find the specified shared folder we have to bail out here
return nil, err return nil, err
@@ -948,6 +943,14 @@ func (f *Fs) listSharedFolders(ctx context.Context, callback func(fs.DirEntry) e
return nil return nil
} }
// sharedFolderName returns the shared folder name in root, which is its first
// path component. root must be the trimmed root as produced by setRoot (no
// leading slash).
func sharedFolderName(root string) string {
name, _, _ := strings.Cut(root, "/")
return name
}
// findSharedFolder find the id for a given shared folder name // findSharedFolder find the id for a given shared folder name
// somewhat annoyingly there is no endpoint to query a shared folder by it's name // somewhat annoyingly there is no endpoint to query a shared folder by it's name
// so our only option is to iterate over all shared folders // so our only option is to iterate over all shared folders
+15
View File
@@ -188,6 +188,21 @@ func TestInternalCheckPathLength(t *testing.T) {
} }
} }
func TestInternalSharedFolderName(t *testing.T) {
for _, test := range []struct {
root string
want string
}{
{root: "", want: ""},
{root: "SharedFolder", want: "SharedFolder"},
{root: "SharedFolder/subdir", want: "SharedFolder"},
{root: "SharedFolder/subdir/deeper", want: "SharedFolder"},
{root: "SharedFolder/subdir/deeper/deepest", want: "SharedFolder"},
} {
assert.Equal(t, test.want, sharedFolderName(test.root), test.root)
}
}
func TestPaperExportRemote(t *testing.T) { func TestPaperExportRemote(t *testing.T) {
ctx := context.Background() ctx := context.Background()
info := &files.FileMetadata{ info := &files.FileMetadata{