rclone-api 1.0.99__py2.py3-none-any.whl → 1.1.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rclone_api/s3/chunk_uploader.py +30 -17
- {rclone_api-1.0.99.dist-info → rclone_api-1.1.0.dist-info}/METADATA +1 -1
- {rclone_api-1.0.99.dist-info → rclone_api-1.1.0.dist-info}/RECORD +7 -7
- {rclone_api-1.0.99.dist-info → rclone_api-1.1.0.dist-info}/LICENSE +0 -0
- {rclone_api-1.0.99.dist-info → rclone_api-1.1.0.dist-info}/WHEEL +0 -0
- {rclone_api-1.0.99.dist-info → rclone_api-1.1.0.dist-info}/entry_points.txt +0 -0
- {rclone_api-1.0.99.dist-info → rclone_api-1.1.0.dist-info}/top_level.txt +0 -0
rclone_api/s3/chunk_uploader.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _thread
|
|
1
2
|
import json
|
|
2
3
|
import os
|
|
3
4
|
import time
|
|
@@ -294,22 +295,23 @@ def file_chunker(
|
|
|
294
295
|
chunk_size = upload_info.chunk_size
|
|
295
296
|
src = Path(file_path)
|
|
296
297
|
# Mounted files may take a while to appear, so keep retrying.
|
|
297
|
-
file_size = _get_file_size(src, timeout=60)
|
|
298
|
-
part_number = 1
|
|
299
|
-
done_part_numbers: set[int] = {
|
|
300
|
-
p.part_number for p in upload_state.parts if p is not None
|
|
301
|
-
}
|
|
302
|
-
num_parts = upload_info.total_chunks()
|
|
303
|
-
|
|
304
|
-
def next_part_number() -> int | None:
|
|
305
|
-
nonlocal part_number
|
|
306
|
-
while part_number in done_part_numbers:
|
|
307
|
-
part_number += 1
|
|
308
|
-
if part_number > num_parts:
|
|
309
|
-
return None
|
|
310
|
-
return part_number
|
|
311
298
|
|
|
312
299
|
try:
|
|
300
|
+
file_size = _get_file_size(src, timeout=60)
|
|
301
|
+
part_number = 1
|
|
302
|
+
done_part_numbers: set[int] = {
|
|
303
|
+
p.part_number for p in upload_state.parts if p is not None
|
|
304
|
+
}
|
|
305
|
+
num_parts = upload_info.total_chunks()
|
|
306
|
+
|
|
307
|
+
def next_part_number() -> int | None:
|
|
308
|
+
nonlocal part_number
|
|
309
|
+
while part_number in done_part_numbers:
|
|
310
|
+
part_number += 1
|
|
311
|
+
if part_number > num_parts:
|
|
312
|
+
return None
|
|
313
|
+
return part_number
|
|
314
|
+
|
|
313
315
|
while not should_stop():
|
|
314
316
|
curr_parth_num = next_part_number()
|
|
315
317
|
if curr_parth_num is None:
|
|
@@ -433,6 +435,7 @@ def upload_file_multipart(
|
|
|
433
435
|
chunk_size: int = 16 * 1024 * 1024, # Default chunk size is 16MB; can be overridden
|
|
434
436
|
retries: int = 20,
|
|
435
437
|
max_chunks_before_suspension: int | None = None,
|
|
438
|
+
abort_transfer_on_failure: bool = False,
|
|
436
439
|
) -> MultiUploadResult:
|
|
437
440
|
"""Upload a file to the bucket using multipart upload with customizable chunk size."""
|
|
438
441
|
file_size = os.path.getsize(str(file_path))
|
|
@@ -494,7 +497,13 @@ def upload_file_multipart(
|
|
|
494
497
|
output=filechunks,
|
|
495
498
|
max_chunks=max_chunks_before_suspension,
|
|
496
499
|
) -> None:
|
|
497
|
-
|
|
500
|
+
try:
|
|
501
|
+
file_chunker(
|
|
502
|
+
upload_state=upload_state, output=output, max_chunks=max_chunks
|
|
503
|
+
)
|
|
504
|
+
except Exception:
|
|
505
|
+
_thread.interrupt_main()
|
|
506
|
+
raise
|
|
498
507
|
|
|
499
508
|
try:
|
|
500
509
|
thread_chunker = Thread(target=chunker_task, daemon=True)
|
|
@@ -507,7 +516,11 @@ def upload_file_multipart(
|
|
|
507
516
|
break
|
|
508
517
|
|
|
509
518
|
def task(upload_info=upload_info, file_chunk=file_chunk):
|
|
510
|
-
|
|
519
|
+
try:
|
|
520
|
+
return handle_upload(upload_info, file_chunk)
|
|
521
|
+
except Exception:
|
|
522
|
+
_thread.interrupt_main()
|
|
523
|
+
raise
|
|
511
524
|
|
|
512
525
|
fut = executor.submit(task)
|
|
513
526
|
|
|
@@ -540,7 +553,7 @@ def upload_file_multipart(
|
|
|
540
553
|
f"Multipart upload completed: {file_path} to {bucket_name}/{object_name}"
|
|
541
554
|
)
|
|
542
555
|
except Exception:
|
|
543
|
-
if upload_info.upload_id:
|
|
556
|
+
if upload_info.upload_id and abort_transfer_on_failure:
|
|
544
557
|
try:
|
|
545
558
|
s3_client.abort_multipart_upload(
|
|
546
559
|
Bucket=bucket_name, Key=object_name, UploadId=upload_info.upload_id
|
|
@@ -25,12 +25,12 @@ rclone_api/cmd/list_files.py,sha256=x8FHODEilwKqwdiU1jdkeJbLwOqUkUQuDWPo2u_zpf0,
|
|
|
25
25
|
rclone_api/experimental/flags.py,sha256=AHbTaFHuyYFm3pjdvbQ100jztOXOdNuxalMr8UjXnV4,4097
|
|
26
26
|
rclone_api/s3/api.py,sha256=VstlaEnBjO2JDQuCRLdTfUGvQLbfshlXXhAzimFv4Vc,3763
|
|
27
27
|
rclone_api/s3/basic_ops.py,sha256=hK3366xhVEzEcjz9Gk_8lFx6MRceAk72cax6mUrr6ko,2104
|
|
28
|
-
rclone_api/s3/chunk_uploader.py,sha256=
|
|
28
|
+
rclone_api/s3/chunk_uploader.py,sha256=txnNtugKcTb1UDmPbqWp3K-yLUDEkeW72nEnQnDcA8o,18336
|
|
29
29
|
rclone_api/s3/create.py,sha256=SK3IGHZwsSkoG4Zb4NCphcVg9_f7VifDKng-tExMS2s,3088
|
|
30
30
|
rclone_api/s3/types.py,sha256=81_3jwg6MGIxC-GxL-6zANzKO6au9C0BWvAqRyODxOM,1361
|
|
31
|
-
rclone_api-1.0.
|
|
32
|
-
rclone_api-1.0.
|
|
33
|
-
rclone_api-1.0.
|
|
34
|
-
rclone_api-1.0.
|
|
35
|
-
rclone_api-1.0.
|
|
36
|
-
rclone_api-1.0.
|
|
31
|
+
rclone_api-1.1.0.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
|
32
|
+
rclone_api-1.1.0.dist-info/METADATA,sha256=lWksanXlrw5bUyZxWDjFpntBvxsBWd2IBImny4OZRZs,4478
|
|
33
|
+
rclone_api-1.1.0.dist-info/WHEEL,sha256=rF4EZyR2XVS6irmOHQIJx2SUqXLZKRMUrjsg8UwN-XQ,109
|
|
34
|
+
rclone_api-1.1.0.dist-info/entry_points.txt,sha256=6eNqTRXKhVf8CpWNjXiOa_0Du9tHiW_HD2iQSXRsUg8,132
|
|
35
|
+
rclone_api-1.1.0.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
|
36
|
+
rclone_api-1.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|