~bmerry/duplicity/pydrive-id-cache

Viewing all changes in revision 1101.

  • Committer: Bruce Merry
  • Date: 2015-06-16 11:08:33 UTC
  • Revision ID: bruce@brucemerry.org.za-20150616110833-odo0euc1f78cdusf
Add an ID cache to the PyDrive backend.

This is an in-memory cache mapping filenames to object IDs. This potentially
speeds up searching for a filename (although there is some cost to validate the
cache on each use). It also ensures that running _query immediately after _put
will find the file, even if the server doesn't have list-after-write
consistency (Google Cloud Storage doesn't, but I can't find any info on Drive).

There are also a number of other improvements:
- Putting a file with a filename that already exists will replace the file
  in-place, instead of creating a new file with identical filename (which
  Google Drive allows).
- id_by_name now does a targeted search for just the filename, instead of
  iterating over a complete directory listing.
- Added _error_code to map 404 errors to backend_not_found
- Files in the trash are excluded from listings
- Print a warning when trying to delete a file that doesn't exist.

This should fix cases where duplicate filenames are created, but it doesn't yet
deal explicitly with cases where they already exist (it's untested).

There is also a race condition where if a file is externally deleted during
_delete, it will raise an exception (which is mapped to backend_not_found).
That is probably acceptable behaviour, but the behaviour really ought to be
consistent.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: