Merge lp:~crosser/duplicity/dpbx-fix-file-listing into lp:~duplicity-team/duplicity/0.8-series

Proposed by Eugene Crosser
Status: Rejected
Rejected by: edso
Proposed branch: lp:~crosser/duplicity/dpbx-fix-file-listing
Merge into: lp:~duplicity-team/duplicity/0.8-series
Diff against target: 40 lines (+13/-9)
1 file modified
duplicity/backends/dpbxbackend.py (+13/-9)
To merge this branch: bzr merge lp:~crosser/duplicity/dpbx-fix-file-listing
Reviewer Review Type Date Requested Status
edso Needs Fixing
Review via email: mp+334274@code.launchpad.net

Description of the change

dpbxbackend: do not crash when remote directory is empty (always empty on first run).

To post a comment you must log in.
Revision history for this message
edso (ed.so) wrote :

hi,

that workaround looks fishy to me. it will also mask other ListFolderErrors, even ones with a proper cause, that the user needs to see to take appropriate action.

can you dig into the error and find out the detailed error, so you might only ignore this specific error?

another less invasive workaround would be placing a dummy file in the new folder during creation.

probably the correct solution would be raising a bug ticket over at
  https://github.com/dropbox/dropbox-sdk-python/issues

thanks!.. ede/duply.net

review: Needs Fixing
Revision history for this message
Eugene Crosser (crosser) wrote :

Dropbox API probably works as designed: apparently it's actually not and 'empty folder' but 'non-existent folder':

```
ApiError('331ae42f2ac881f10caefc800e59e35b', ListFolderError(u'path', LookupError(u'not_found', None)))
```

It is non-trivial to check the contents of `ListFolderError`: it is a subcluss of `Union` which is a subclass of `Composite` which is a subclass of `Validator` which is much deeper than I am ready do dig.

My goal was to make duplicity work (for me), not to learn Dropbox API. Sorry.

Revision history for this message
Kenneth Loafman (kenneth-loafman) wrote :

There is already a bug report: https://github.com/dropbox/dropbox-sdk-python/issues/35

The third comment has a code snippet for handling the error. Maybe adopt that?

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'duplicity/backends/dpbxbackend.py'
2--- duplicity/backends/dpbxbackend.py 2017-07-11 14:55:38 +0000
3+++ duplicity/backends/dpbxbackend.py 2017-11-25 12:19:19 +0000
4@@ -41,7 +41,7 @@
5 from dropbox import Dropbox
6 from dropbox.exceptions import AuthError, BadInputError, ApiError
7 from dropbox.files import UploadSessionCursor, CommitInfo, WriteMode, \
8- GetMetadataError, DeleteError, UploadSessionLookupError
9+ GetMetadataError, DeleteError, UploadSessionLookupError, ListFolderError
10 from dropbox.oauth import DropboxOAuth2FlowNoRedirect
11 from requests.exceptions import ConnectionError
12 import time
13@@ -383,15 +383,19 @@
14 remote_dir = '/' + urllib.unquote(self.parsed_url.path.lstrip('/')).rstrip()
15
16 log.Debug('dpbx.files_list_folder(%s)' % remote_dir)
17- resp = self.api_client.files_list_folder(remote_dir)
18- log.Debug('dpbx.list(%s): %s' % (remote_dir, resp))
19-
20 res = []
21- while True:
22- res.extend([entry.name for entry in resp.entries])
23- if not resp.has_more:
24- break
25- resp = self.api_client.files_list_folder_continue(resp.cursor)
26+ try:
27+ resp = self.api_client.files_list_folder(remote_dir)
28+ log.Debug('dpbx.list(%s): %s' % (remote_dir, resp))
29+
30+ while True:
31+ res.extend([entry.name for entry in resp.entries])
32+ if not resp.has_more:
33+ break
34+ resp = self.api_client.files_list_folder_continue(resp.cursor)
35+ except ApiError as e:
36+ if not isinstance(e.error, ListFolderError):
37+ raise
38
39 # Warn users of old version dpbx about automatically renamed files
40 self.check_renamed_files(res)

Subscribers

People subscribed via source and target branches