dropbox-restore
dropbox-restore copied to clipboard
Getting a List Revision Error
i am trying to restore a folder on dropbox and using the modified script by Inamul so as to make it work with APIv2. But getting this error. Not really able to understand why this error is happening. If somebody can help or guide on how to fix this.
Traceback (most recent call last):
File "C:\Users\A3003\Desktop\restore.py", line 116, in
Same error here
Found a workaround: (I'm using this commit because dropbox API changed)
This error seems to occur when there is an empty new folder created recently on the directory. I made an try except to simply skip the function if this error occurs:
` def restore_file(client, path, cutoff_datetime, is_deleted, verbose=False):
try:
revisions = client.files_list_revisions(path.encode('utf8'))
except:
print('custom skip on: ', path.encode('utf8'))
return
`
also, there is another error from similar origins when get the revision_dict keys: max() don't work if it is empty. so I also changed this line:
if max(revision_dict.keys()) < cutoff_datetime:
for this:
if len(revision_dict.keys()) > 0 and max(revision_dict.keys()) < cutoff_datetime:
This worked (almost) perfectly to restore an Unity 3D project folder that was corrupted. Hope it helps.
*Sorry for bad english...
This helped me as well - do you want to create a Pull Request or do you want me to?
but it's true, this is a diff for the other (working for me too) version of restore.py.
Pardon my less knowledge about python. I am not sure exactly where to insert the code given by Lightclawjl. I tried inserting the code but its gave me some error message about the "except" part. Dont remember the exact error. Can anybody repost the code here merging the additional codes provided by Lightclawjl . And thanks a lot Lightclawjl for posting the resolution.
I tried the workaround of Lightclawjl, but it skipped many directories which were not empty, and their files are actually in the cache directory. Is there another way to correct the code?
For A3003: You should change the revisions = client.files_... line for the 4 lines of Lightclawjl, but be aware that indenting is important in python, to try and except has to be indented as revisions = client.files_... was, the 2 other lines 4 spaces more to the right.
Hi, Thanks for original author and all others for work to keep this up-to-date. I encountered both the DropBox API problem and this error so updated the script. I don't have time to pull request right now (and haven't tested it on other platforms, etc which the original author seems to require) so here's a quick Gist of it:
https://gist.github.com/Arakade/50f47ab38d8ab0c3bb2ebf29d2795119
My attempt to restore a Unity Project got stuck in Temp so I added ability to disable recursion. I've not yet added as a command-line option so disable by hacking line 119: change "do_recurse=False" to "do_recurse=True".
HTH for future horrified individuals that find themselves here!
Hey Arakade, i tried the script that you provided. i tried that by creating a test folder on dropbox and putting some files in that folder and then deleting them afterwards. Now when i try to restore the files its "Skips" the files. For example i added the files on 6th Dec. deleted them on 9th Dec. now when i run the command with date set to 8th Dec it skips the files where as it should recover the files as the files were there in the folder on 8th. Please help.
+1 to @A3003's comment, any thoughts @Arakade?
nvm @A3003 comment out the else clause on line 74 which states that if the files were created before the cut off date don't bother.