dropbox-restore icon indicating copy to clipboard operation
dropbox-restore copied to clipboard

Getting a List Revision Error

Open A3003 opened this issue 7 years ago • 10 comments

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 main() File "C:\Users\A3003\Desktop\restore.py", line 112, in main restore_folder(client, root_path, cutoff_datetime, verbose=True) File "C:\Users\A3003\Desktop\restore.py", line 91, in restore_folder restore_folder(client, item.path_lower, cutoff_datetime, verbose) File "C:\Users\A3003\Desktop\restore.py", line 91, in restore_folder restore_folder(client, item.path_lower, cutoff_datetime, verbose) File "C:\Users\A3003\Desktop\restore.py", line 96, in restore_folder False, verbose) File "C:\Users\A3003\Desktop\restore.py", line 52, in restore_file revisions = client.files_list_revisions(path.encode('utf8')) File "C:\Python27\lib\site-packages\dropbox\base.py", line 842, in files_list_revisions None, File "C:\Python27\lib\site-packages\dropbox\dropbox.py", line 256, in request user_message_locale) dropbox.exceptions.ApiError: ApiError('57fdb68b14f6936763e44440edd3b5dc', ListRevisionsError(u'path', LookupError(u'not_file', None)))

A3003 avatar Aug 24 '17 22:08 A3003

Same error here

Jean-Low avatar Aug 29 '17 14:08 Jean-Low

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...

Jean-Low avatar Aug 29 '17 14:08 Jean-Low

This helped me as well - do you want to create a Pull Request or do you want me to?

elsigh avatar Sep 03 '17 18:09 elsigh

but it's true, this is a diff for the other (working for me too) version of restore.py.

elsigh avatar Sep 03 '17 18:09 elsigh

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.

A3003 avatar Sep 04 '17 18:09 A3003

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.

tothbog avatar Oct 11 '17 20:10 tothbog

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!

Arakade avatar Nov 09 '17 11:11 Arakade

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.

A3003 avatar Dec 22 '17 10:12 A3003

+1 to @A3003's comment, any thoughts @Arakade?

olgageletina avatar Jul 20 '18 00:07 olgageletina

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.

olgageletina avatar Jul 20 '18 00:07 olgageletina