diff --git a/fs/operations/lsjson.go b/fs/operations/lsjson.go index 067681956..176c2cb9f 100644 --- a/fs/operations/lsjson.go +++ b/fs/operations/lsjson.go @@ -314,6 +314,9 @@ func StatJSON(ctx context.Context, fsrc fs.Fs, remote string, opt *ListJSONOpt) } } // Must be a directory here + // + // Remove trailing / as rclone listings won't have them + remote = strings.TrimRight(remote, "/") parent := path.Dir(remote) if parent == "." || parent == "/" { parent = "" diff --git a/fs/operations/lsjson_test.go b/fs/operations/lsjson_test.go index c9be36173..7fbe67318 100644 --- a/fs/operations/lsjson_test.go +++ b/fs/operations/lsjson_test.go @@ -292,6 +292,15 @@ func TestStatJSON(t *testing.T) { Name: "sub", IsDir: true, }, + }, { + name: "DirWithTrailingSlash", + remote: "sub/", + opt: operations.ListJSONOpt{}, + want: &operations.ListJSONItem{ + Path: "sub", + Name: "sub", + IsDir: true, + }, }, { name: "File", remote: "file1",