Google Drive: Multiple Files with the Same Path
July 9, 2015
(EDIT: I’ve turned this post into an FAQ entry)
In Autosync for Google Drive some users occasionally may run into an error “Cannot upload - multiple files with the same path:…“. It can also be “Cannot delete” or “Cannot download…“ as shown in this screenshot
What’s happening here?
It turned out that in Google Drive you can easily have multiple files with the exact same name in the same folder. It’s rather easy to create such a situation. For example, you can use the Google Drive official app on Android to upload a file, say ParisVisit.txt where you keep your notes about your stay in Paris. Some time later you edit the file, add more notes, and upload the newly updated file to the same folder. Instead of overwriting the same file which already exists there (perhaps after asking the user to confirm first), Google Drive merrily let you create another file with exact same name but with different content. In the Google Drive app you would see this
If you open your laptop, go to Google Drive website, you’d see a similar picture
There is absolutely no way to know which file is which without opening all those files, one by one, and examining their contents. And immediately forget which is which the moment we close the files! We all probably agree this is rather suboptimal user experience, to say the least.
This situation happens when the user uploads the same file several times, accepts the default and doesn’t know the implication (certainly this is not the user’s fault). It’s also possible that some apps (including Autosync for Google Drive but unlikely) forget to check if a filename is already in use and insert a new file under the same name.
When Autosync for Google Drive detects this situation it refuses to touch the file in Google Drive. Simply because it does not know which one is the right one. If you see the error message “Cannot … - multiple files with the same path:…“ you must go to Google Drive yourself, examine which files you want to keep, delete the others, or rename them so that each file has a unique name.
Depending on how many such files do you have this can be a tedious process. Autosync for Google Drive does handle one subcase automatically. If there are multiple files in Google Drive folder with the same name and same content, it keep one copy and delete all the others. I can’t imagine what multiple copies of the same thing under the same name is good for. If you know one, please let me know. I’ll revert that feature.
I may also try to be clever and auto-rename those files when download them to the folder in the device. The first “ParisVisit.txt” gets to keep its name but the second one would become “ParisVisit (1).txt”, the third would be “ParisVisit (2).txt”, etc… This is what the Google Drive sync client on desktop does
I chose not to auto-rename, at least not yet, because I found ways to get Google Drive sync client on desktop into data-loss situation. It tries to be clever but in reality is not clever enough. It’s better to stay simplictic but safe than being clever but dangerous.
(PS I don’t know how Google engineers reasoned when they decided to implement it that way. I have several hypotheses but I save them for an evening in the pub where we programmers tell each other war stories)