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
=== modified file 'duplicity/backends/dpbxbackend.py'
--- duplicity/backends/dpbxbackend.py 2017-07-11 14:55:38 +0000
+++ duplicity/backends/dpbxbackend.py 2017-11-25 12:19:19 +0000
@@ -41,7 +41,7 @@
41from dropbox import Dropbox41from dropbox import Dropbox
42from dropbox.exceptions import AuthError, BadInputError, ApiError42from dropbox.exceptions import AuthError, BadInputError, ApiError
43from dropbox.files import UploadSessionCursor, CommitInfo, WriteMode, \43from dropbox.files import UploadSessionCursor, CommitInfo, WriteMode, \
44 GetMetadataError, DeleteError, UploadSessionLookupError44 GetMetadataError, DeleteError, UploadSessionLookupError, ListFolderError
45from dropbox.oauth import DropboxOAuth2FlowNoRedirect45from dropbox.oauth import DropboxOAuth2FlowNoRedirect
46from requests.exceptions import ConnectionError46from requests.exceptions import ConnectionError
47import time47import time
@@ -383,15 +383,19 @@
383 remote_dir = '/' + urllib.unquote(self.parsed_url.path.lstrip('/')).rstrip()383 remote_dir = '/' + urllib.unquote(self.parsed_url.path.lstrip('/')).rstrip()
384384
385 log.Debug('dpbx.files_list_folder(%s)' % remote_dir)385 log.Debug('dpbx.files_list_folder(%s)' % remote_dir)
386 resp = self.api_client.files_list_folder(remote_dir)
387 log.Debug('dpbx.list(%s): %s' % (remote_dir, resp))
388
389 res = []386 res = []
390 while True:387 try:
391 res.extend([entry.name for entry in resp.entries])388 resp = self.api_client.files_list_folder(remote_dir)
392 if not resp.has_more:389 log.Debug('dpbx.list(%s): %s' % (remote_dir, resp))
393 break390
394 resp = self.api_client.files_list_folder_continue(resp.cursor)391 while True:
392 res.extend([entry.name for entry in resp.entries])
393 if not resp.has_more:
394 break
395 resp = self.api_client.files_list_folder_continue(resp.cursor)
396 except ApiError as e:
397 if not isinstance(e.error, ListFolderError):
398 raise
395399
396 # Warn users of old version dpbx about automatically renamed files400 # Warn users of old version dpbx about automatically renamed files
397 self.check_renamed_files(res)401 self.check_renamed_files(res)

Subscribers

People subscribed via source and target branches