Skip to content

Commit

Permalink
fix: form retry not working by no resume recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
lihsai0 committed Sep 12, 2024
1 parent dbc5668 commit 7519a89
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion qiniu/services/storage/uploaders/_default_retrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def get_default_retrier(
"""
retry_policies = []
upload_service_names = [ServiceName.UP]
handle_change_region = None

if accelerate_uploading:
retry_policies.append(AccUnavailableRetryPolicy())
Expand All @@ -196,14 +197,16 @@ def get_default_retrier(
record_delete_handler=progress_record.delete,
record_exists_handler=progress_record.exists
))
def handle_change_region(_):
progress_record.delete()

retry_policies += [
EndpointsRetryPolicy(skip_init_context=True),
RegionsRetryPolicy(
regions_provider=regions_provider,
service_names=upload_service_names,
preferred_endpoints_provider=preferred_endpoints_provider,
on_change_region=lambda _: progress_record.delete()
on_change_region=handle_change_region
)
]

Expand Down
22 changes: 22 additions & 0 deletions tests/cases/test_services/test_storage/test_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,28 @@ def test_put_file_with_callback(
assert ret['x-qn-meta']['name'] == 'qiniu'
assert ret['x-qn-meta']['age'] == '18'

@pytest.mark.parametrize('temp_file', [64 * KB, 10 * MB], indirect=True)
def test_put_file_with_regions_retry(
self,
qn_auth,
bucket_name,
temp_file,
regions_with_fake_endpoints,
get_remote_object_headers_and_md5,
get_key
):
key = get_key('test_file_with_form_regions_retry')
token = qn_auth.upload_token(bucket_name, key)
ret, info = put_file(
token,
key,
temp_file.path,
regions=regions_with_fake_endpoints
)
_, actual_md5 = get_remote_object_headers_and_md5(key=key)
assert ret['key'] == key
assert actual_md5 == temp_file.md5

def test_put_data_with_callback(
self,
qn_auth,
Expand Down

0 comments on commit 7519a89

Please sign in to comment.