OK, this is what I thought. Sigh.
Google Drive has a really weird organisation system because it was made to store documents from their productivity applications, not files. The thing was retrofitted with "folders" and "files" which are neither folders not files.
Each "folder" is just a label against a numeric identifier. Two or more numeric identifiers may have the same label, i.e. the same "folder name". Same for "files", which are just numeric identifiers with attached data.
When you take a backup, we have to translate your "folder names" into the actual numeric ID used by Google Drive. To do that, we ask Google Drive to list all folders in the drive root, find the one which looks like the first part of your "file path" (_web
). Then we use that ID to gets its contents and find something which looks like the second path of your "file path" (backup
). And so on and so forth. If an entity isn't found, we create a new "folder".
Here's the thing. Google Drive may NOT return the folder we're looking for, for reasons that have to do with Google Drive's implementation of their API, not our code (we use the method they themselves recommend in their documentation, i.e. a search query in the form of name='what_you_told_us' and mimeType = 'application/vnd.google-apps.folder'
). In this case, a new one will be created. Moreover, Google Drive doesn't specify if a folder is in the trash or not when returning the search results, nor do they provide a way to specify "is not in the trash" in the search query (since there is no field specifying the "folder" / "file" is in the trash, i.e. you can't search against something they do not report). Therefore, we might end up using a folder that's in the trash, which is what happened with you the second time you tried. I am still trying to figure out if anyone has ever found a solution to that, since a different part of their documentation claims there SHOULD be a "trashed" field to tell us if a file / folder is trashed. Either the first part of their documentation is right and we can't exclude trashed folders, or the second is and we can exclude trashed folders. Yes, that's the quality of Google's documentation we have to work withβ¦
Even if I do find to work around the "folder is in the trash" problem, the other problem which makes Google Drive sometimes β albeit very rarely β not return information about an existing "folder" seems to be unsolvable as it solely depends on the Google Drive API returning trustworthy information.
Nicholas K. Dionysopoulos
Lead Developer and Director
π¬π·Greek: native π¬π§English: excellent π«π·French: basic β’ π My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!