mirror of
https://github.com/samschott/maestral.git
synced 2024-11-11 11:36:35 +03:00
[client] retry BadInputError matching v1_retired...
... up to 3 times with backoff of 1 sec
This commit is contained in:
parent
6f0e00d517
commit
046749dff9
@ -63,6 +63,7 @@ from .exceptions import (
|
||||
NotFoundError,
|
||||
NotLinkedError,
|
||||
DataCorruptionError,
|
||||
BadInputError,
|
||||
)
|
||||
from .errorhandling import (
|
||||
convert_api_errors,
|
||||
@ -235,6 +236,7 @@ class DropboxClient:
|
||||
|
||||
return 0
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def unlink(self) -> None:
|
||||
"""
|
||||
Unlinks the Dropbox account. The password will be deleted from the provided
|
||||
@ -460,6 +462,7 @@ class DropboxClient:
|
||||
def get_account_info(self, dbid: str) -> Account:
|
||||
...
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def get_account_info(self, dbid=None):
|
||||
"""
|
||||
Gets current account information.
|
||||
@ -501,6 +504,7 @@ class DropboxClient:
|
||||
|
||||
return self._cached_account_info
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def get_space_usage(self) -> SpaceUsage:
|
||||
"""
|
||||
:returns: The space usage of the currently linked account.
|
||||
@ -533,6 +537,7 @@ class DropboxClient:
|
||||
|
||||
return convert_space_usage(res)
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def get_metadata(
|
||||
self, dbx_path: str, include_deleted: bool = False
|
||||
) -> Metadata | None:
|
||||
@ -555,6 +560,7 @@ class DropboxClient:
|
||||
except (NotFoundError, PathError):
|
||||
return None
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def list_revisions(
|
||||
self, dbx_path: str, mode: str = "path", limit: int = 10
|
||||
) -> list[FileMetadata]:
|
||||
@ -574,6 +580,7 @@ class DropboxClient:
|
||||
|
||||
return [convert_metadata(entry) for entry in res.entries]
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def restore(self, dbx_path: str, rev: str) -> FileMetadata:
|
||||
"""
|
||||
Restore an old revision of a file.
|
||||
@ -589,6 +596,7 @@ class DropboxClient:
|
||||
|
||||
return convert_metadata(res)
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
@retry_on_error(DataCorruptionError, MAX_TRANSFER_RETRIES)
|
||||
def download(
|
||||
self,
|
||||
@ -773,6 +781,7 @@ class DropboxClient:
|
||||
|
||||
return convert_metadata(res)
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
@retry_on_error(DataCorruptionError, MAX_TRANSFER_RETRIES)
|
||||
def _upload_helper(
|
||||
self,
|
||||
@ -802,6 +811,7 @@ class DropboxClient:
|
||||
|
||||
return md
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
@retry_on_error(DataCorruptionError, MAX_TRANSFER_RETRIES)
|
||||
def _upload_session_start_helper(
|
||||
self,
|
||||
@ -829,6 +839,7 @@ class DropboxClient:
|
||||
|
||||
return session_start.session_id
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
@retry_on_error(DataCorruptionError, MAX_TRANSFER_RETRIES)
|
||||
def _upload_session_append_helper(
|
||||
self,
|
||||
@ -870,6 +881,7 @@ class DropboxClient:
|
||||
if sync_event:
|
||||
sync_event.completed = f.tell()
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
@retry_on_error(DataCorruptionError, MAX_TRANSFER_RETRIES)
|
||||
def _upload_session_finish_helper(
|
||||
self,
|
||||
@ -929,6 +941,7 @@ class DropboxClient:
|
||||
|
||||
return md
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def remove(
|
||||
self, dbx_path: str, parent_rev: str | None = None
|
||||
) -> FileMetadata | FolderMetadata:
|
||||
@ -946,6 +959,7 @@ class DropboxClient:
|
||||
|
||||
return convert_metadata(res.metadata)
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def remove_batch(
|
||||
self, entries: Sequence[tuple[str, str | None]], batch_size: int = 900
|
||||
) -> list[FileMetadata | FolderMetadata | MaestralApiError]:
|
||||
@ -1023,6 +1037,7 @@ class DropboxClient:
|
||||
|
||||
return result_list
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def move(
|
||||
self, dbx_path: str, new_path: str, autorename: bool = False
|
||||
) -> FileMetadata | FolderMetadata:
|
||||
@ -1047,6 +1062,7 @@ class DropboxClient:
|
||||
|
||||
return convert_metadata(res.metadata)
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def make_dir(self, dbx_path: str, autorename: bool = False) -> FolderMetadata:
|
||||
"""
|
||||
Creates a folder on Dropbox.
|
||||
@ -1063,6 +1079,7 @@ class DropboxClient:
|
||||
md = cast(files.FolderMetadata, res.metadata)
|
||||
return convert_metadata(md)
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def make_dir_batch(
|
||||
self,
|
||||
dbx_paths: list[str],
|
||||
@ -1135,6 +1152,7 @@ class DropboxClient:
|
||||
|
||||
return result_list
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def share_dir(self, dbx_path: str, **kwargs) -> FolderMetadata | None:
|
||||
"""
|
||||
Converts a Dropbox folder to a shared folder. Creates the folder if it does not
|
||||
@ -1198,6 +1216,7 @@ class DropboxClient:
|
||||
else:
|
||||
return None
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def get_latest_cursor(
|
||||
self, dbx_path: str, include_non_downloadable_files: bool = False, **kwargs
|
||||
) -> str:
|
||||
@ -1224,6 +1243,7 @@ class DropboxClient:
|
||||
|
||||
return res.cursor
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def list_folder(
|
||||
self,
|
||||
dbx_path: str,
|
||||
@ -1261,6 +1281,7 @@ class DropboxClient:
|
||||
|
||||
return self.flatten_results(list(iterator))
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def list_folder_iterator(
|
||||
self,
|
||||
dbx_path: str,
|
||||
@ -1311,10 +1332,12 @@ class DropboxClient:
|
||||
res = self._list_folder_continue_helper(res.cursor)
|
||||
yield convert_list_folder_result(res)
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
@retry_on_error(requests.exceptions.ReadTimeout, MAX_LIST_FOLDER_RETRIES, backoff=3)
|
||||
def _list_folder_continue_helper(self, cursor: str) -> files.ListFolderResult:
|
||||
return self.dbx.files_list_folder_continue(cursor)
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def wait_for_remote_changes(self, last_cursor: str, timeout: int = 40) -> bool:
|
||||
"""
|
||||
Waits for remote changes since ``last_cursor``. Call this method after
|
||||
@ -1359,6 +1382,7 @@ class DropboxClient:
|
||||
iterator = self.list_remote_changes_iterator(last_cursor)
|
||||
return self.flatten_results(list(iterator))
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def list_remote_changes_iterator(
|
||||
self, last_cursor: str
|
||||
) -> Iterator[ListFolderResult]:
|
||||
@ -1384,6 +1408,7 @@ class DropboxClient:
|
||||
res = self.dbx.files_list_folder_continue(res.cursor)
|
||||
yield convert_list_folder_result(res)
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def create_shared_link(
|
||||
self,
|
||||
dbx_path: str,
|
||||
@ -1434,6 +1459,7 @@ class DropboxClient:
|
||||
|
||||
return convert_shared_link_metadata(res)
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def revoke_shared_link(self, url: str) -> None:
|
||||
"""
|
||||
Revokes a shared link.
|
||||
@ -1443,6 +1469,7 @@ class DropboxClient:
|
||||
with convert_api_errors():
|
||||
self.dbx.sharing_revoke_shared_link(url)
|
||||
|
||||
@retry_on_error(BadInputError, max_retries=3, backoff=2, msg_regex="v1_retired")
|
||||
def list_shared_links(
|
||||
self, dbx_path: str | None = None
|
||||
) -> list[SharedLinkMetadata]:
|
||||
|
Loading…
Reference in New Issue
Block a user