diff options
author | Victor Shyba <victor1984@riseup.net> | 2017-10-27 19:39:25 -0300 |
---|---|---|
committer | Victor Shyba <victor1984@riseup.net> | 2017-10-27 19:49:28 -0300 |
commit | 72956174187fa2fccbb060d04d4809797657e029 (patch) | |
tree | 658177e6bb96bce4d91b9901d032bda0fae2e195 /src/leap/soledad/client/_db/blobs/__init__.py | |
parent | f4ab4e15ba2fd6eb06bcd71e8fe04abc903d4ff0 (diff) |
[bug] there is no retry limit for usual transfers
Retry limit was originally specified in #8825 as a protection mechanism,
but #8822 (retry) doesn't specify a retry limit. In fact, blobs is
supposed to retry until transfer is complete using timed delays between
attempts, but never giving up.
-- Related: #8822
-- Related: #8825
Diffstat (limited to 'src/leap/soledad/client/_db/blobs/__init__.py')
-rw-r--r-- | src/leap/soledad/client/_db/blobs/__init__.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/leap/soledad/client/_db/blobs/__init__.py b/src/leap/soledad/client/_db/blobs/__init__.py index 3c8facba..2df315dc 100644 --- a/src/leap/soledad/client/_db/blobs/__init__.py +++ b/src/leap/soledad/client/_db/blobs/__init__.py @@ -107,6 +107,9 @@ class BlobManager(BlobsSynchronizer): The BlobManager can list, put, get, set flags and synchronize blobs stored in local and remote storages. """ + max_decrypt_retries = 3 + concurrent_transfers_limit = 3 + concurrent_writes_limit = 100 def __init__( self, local_path, remote, key, secret, user, token=None, @@ -128,9 +131,6 @@ class BlobManager(BlobsSynchronizer): :type cert_file: str """ super(BlobsSynchronizer, self).__init__() - self.max_retries = 3 - self.concurrent_transfers_limit = 3 - self.concurrent_writes_limit = 100 if local_path: mkdir_p(os.path.dirname(local_path)) self.local = SQLiteBlobBackend(local_path, key=key, user=user) @@ -307,22 +307,23 @@ class BlobManager(BlobsSynchronizer): _, retries = yield self.local.get_sync_status(blob_id) if isinstance(e, InvalidBlob): + max_retries = self.max_decrypt_retries message = "Corrupted blob received from server! ID: %s\n" message += "Error: %r\n" message += "Retries: %s - Attempts left: %s\n" message += "This is either a bug or the contents of the " message += "blob have been tampered with. Please, report to " message += "your provider's sysadmin and submit a bug report." - message %= (blob_id, e, retries, (self.max_retries - retries)) + message %= (blob_id, e, retries, (max_retries - retries)) logger.error(message) - yield self.local.increment_retries(blob_id) + yield self.local.increment_retries(blob_id) - if (retries + 1) >= self.max_retries: - failed_download = SyncStatus.FAILED_DOWNLOAD - yield self.local.update_sync_status( - blob_id, failed_download, namespace=namespace) - raise MaximumRetriesError(e) + if (retries + 1) >= max_retries: + failed_download = SyncStatus.FAILED_DOWNLOAD + yield self.local.update_sync_status( + blob_id, failed_download, namespace=namespace) + raise MaximumRetriesError(e) raise RetriableTransferError(e) |