Semantics of "rclone cat" when the path is a duplicate name?

I am looking into rclones handling of duplicate names and haven’t been able to find common approach across commands or backends.

As an example, I have looked into rclone cat in this situation:

> echo "Hello Duplicate File!"   > ./testfolder1/hello
> echo "Hello Duplicate Folder!" > ./testfolder2/hello/duplicates

> rclone copy ./testfolder1 remote: -v --stats=0
2023/02/01 12:02:38 INFO  : hello: Copied (new)

> rclone copy ./testfolder2 remote: -v --stats=0
2023/02/01 12:02:44 INFO  : hello/duplicates: Copied (new)

> rclone lsl remote:
   23 2023-02-01 12:02:29.539000000 hello
   25 2023-02-01 12:02:32.135000000 hello/duplicates

> rclone cat remote:hello
# What is the expected result?

The above is possible on remotes allowing duplicate names (e.g. Google Drive) and bucket/object based remotes (e.g. S3).

Interestingly, I get different results on Google Drive (Hello Duplicate Folder!) and S3 (Hello Duplicate File!) – and none of them warn that they are presenting only one of two possible answers.

So here is my question: What is the expected output of rclone cat in situations where the path refers to

  • a file and a folder (having the same name) such as rclone cat remote:hello
  • multiple folders (having the same name)
  • multiple files (having the same name)

and should any of these result in a warning or error?

I think the answer to all of this is

  • it is backend dependent
  • most likely it will be the first match the backend comes across

Note that when you specify remote:hello rclone doesn't know at that moment what you are looking for - whether you expect hello to be a file or a directory. You can force rclone to consider it to be a directory by putting a / on the end (though this is somewhat backend dependent also).

So what is happening in the drive example is it finds the directory hello first, then cats all the files in it. Whereas in the s3 example, it finds the file, works out it isn't a directory marker and then cats it.

Possibly, but when you are just acting on a single thing you are invoking a whole pile of special case code which works out whether you meant a file or a directory. That is completely different code which gives the duplicate errors in the sync.

So if this was to give an error, it would need to be implemented in each backend. It would almost certainly take more transactions so slow each backend down for the case where it is trying to decide whether you've asked for the root to be pointing to a file or a directory.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.