rclone-api 1.4.6__py2.py3-none-any.whl → 1.4.8__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/cmd/copy_large_s3.py +5 -13
- rclone_api/cmd/copy_large_s3_finish.py +217 -0
- rclone_api/detail/copy_file_parts.py +109 -17
- rclone_api/process.py +6 -14
- rclone_api/rclone_impl.py +61 -44
- rclone_api/s3/multipart/finished_piece.py +4 -1
- rclone_api/s3/s3_multipart_uploader_by_copy.py +395 -0
- rclone_api/s3/types.py +1 -0
- rclone_api/types.py +13 -0
- rclone_api/util.py +52 -9
- {rclone_api-1.4.6.dist-info → rclone_api-1.4.8.dist-info}/METADATA +1 -1
- {rclone_api-1.4.6.dist-info → rclone_api-1.4.8.dist-info}/RECORD +16 -15
- rclone_api/s3/s3_multipart_uploader.py +0 -138
- {rclone_api-1.4.6.dist-info → rclone_api-1.4.8.dist-info}/LICENSE +0 -0
- {rclone_api-1.4.6.dist-info → rclone_api-1.4.8.dist-info}/WHEEL +0 -0
- {rclone_api-1.4.6.dist-info → rclone_api-1.4.8.dist-info}/entry_points.txt +0 -0
- {rclone_api-1.4.6.dist-info → rclone_api-1.4.8.dist-info}/top_level.txt +0 -0
@@ -1,138 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3/client/upload_part_copy.html
|
3
|
-
* client.upload_part_copy
|
4
|
-
|
5
|
-
|
6
|
-
"""
|
7
|
-
|
8
|
-
# import _thread
|
9
|
-
# import os
|
10
|
-
# import traceback
|
11
|
-
# import warnings
|
12
|
-
# from concurrent.futures import Future, ThreadPoolExecutor
|
13
|
-
# from pathlib import Path
|
14
|
-
# from queue import Queue
|
15
|
-
# from threading import Event, Thread
|
16
|
-
# from typing import Any, Callable
|
17
|
-
|
18
|
-
# from botocore.client import BaseClient
|
19
|
-
|
20
|
-
# from rclone_api.mount_read_chunker import FilePart
|
21
|
-
# from rclone_api.s3.chunk_task import S3FileInfo, file_chunker
|
22
|
-
# from rclone_api.s3.chunk_types import (
|
23
|
-
# FinishedPiece,
|
24
|
-
# UploadInfo,
|
25
|
-
# UploadState,
|
26
|
-
# )
|
27
|
-
# from rclone_api.s3.types import MultiUploadResult
|
28
|
-
# from rclone_api.types import EndOfStream
|
29
|
-
# from rclone_api.util import locked_print
|
30
|
-
|
31
|
-
|
32
|
-
# This is how you upload large parts through multi part upload, then the final call
|
33
|
-
# is to assemble the parts that have already been uploaded through a multi part uploader
|
34
|
-
# and then call complete_multipart_upload to finish the upload
|
35
|
-
# response = (
|
36
|
-
# client.upload_part_copy(
|
37
|
-
# Bucket='string',
|
38
|
-
# CopySource='string' or {'Bucket': 'string', 'Key': 'string', 'VersionId': 'string'},
|
39
|
-
# CopySourceIfMatch='string',
|
40
|
-
# CopySourceIfModifiedSince=datetime(2015, 1, 1),
|
41
|
-
# CopySourceIfNoneMatch='string',
|
42
|
-
# CopySourceIfUnmodifiedSince=datetime(2015, 1, 1),
|
43
|
-
# CopySourceRange='string',
|
44
|
-
# Key='string',
|
45
|
-
# PartNumber=123,
|
46
|
-
# UploadId='string',
|
47
|
-
# SSECustomerAlgorithm='string',
|
48
|
-
# SSECustomerKey='string',
|
49
|
-
# CopySourceSSECustomerAlgorithm='string',
|
50
|
-
# CopySourceSSECustomerKey='string',
|
51
|
-
# RequestPayer='requester',
|
52
|
-
# ExpectedBucketOwner='string',
|
53
|
-
# ExpectedSourceBucketOwner='string'
|
54
|
-
# )
|
55
|
-
|
56
|
-
|
57
|
-
# def upload_task(
|
58
|
-
# info: UploadInfo,
|
59
|
-
# chunk: FilePart,
|
60
|
-
# part_number: int,
|
61
|
-
# retries: int,
|
62
|
-
# ) -> FinishedPiece:
|
63
|
-
# file_or_err: Path | Exception = chunk.get_file()
|
64
|
-
# if isinstance(file_or_err, Exception):
|
65
|
-
# raise file_or_err
|
66
|
-
# file: Path = file_or_err
|
67
|
-
# size = os.path.getsize(file)
|
68
|
-
# retries = retries + 1 # Add one for the initial attempt
|
69
|
-
# for retry in range(retries):
|
70
|
-
# try:
|
71
|
-
# if retry > 0:
|
72
|
-
# locked_print(f"Retrying part {part_number} for {info.src_file_path}")
|
73
|
-
# locked_print(
|
74
|
-
# f"Uploading part {part_number} for {info.src_file_path} of size {size}"
|
75
|
-
# )
|
76
|
-
|
77
|
-
# with open(file, "rb") as f:
|
78
|
-
# part = info.s3_client.upload_part(
|
79
|
-
# Bucket=info.bucket_name,
|
80
|
-
# Key=info.object_name,
|
81
|
-
# PartNumber=part_number,
|
82
|
-
# UploadId=info.upload_id,
|
83
|
-
# Body=f,
|
84
|
-
# )
|
85
|
-
# out: FinishedPiece = FinishedPiece(
|
86
|
-
# etag=part["ETag"], part_number=part_number
|
87
|
-
# )
|
88
|
-
# chunk.dispose()
|
89
|
-
# return out
|
90
|
-
# except Exception as e:
|
91
|
-
# if retry == retries - 1:
|
92
|
-
# locked_print(f"Error uploading part {part_number}: {e}")
|
93
|
-
# chunk.dispose()
|
94
|
-
# raise e
|
95
|
-
# else:
|
96
|
-
# locked_print(f"Error uploading part {part_number}: {e}, retrying")
|
97
|
-
# continue
|
98
|
-
# raise Exception("Should not reach here")
|
99
|
-
|
100
|
-
|
101
|
-
# def prepare_upload_file_multipart(
|
102
|
-
# s3_client: BaseClient,
|
103
|
-
# bucket_name: str,
|
104
|
-
# file_path: Path,
|
105
|
-
# file_size: int | None,
|
106
|
-
# object_name: str,
|
107
|
-
# chunk_size: int,
|
108
|
-
# retries: int,
|
109
|
-
# ) -> UploadInfo:
|
110
|
-
# """Upload a file to the bucket using multipart upload with customizable chunk size."""
|
111
|
-
|
112
|
-
# # Initiate multipart upload
|
113
|
-
# locked_print(
|
114
|
-
# f"Creating multipart upload for {file_path} to {bucket_name}/{object_name}"
|
115
|
-
# )
|
116
|
-
# mpu = s3_client.create_multipart_upload(Bucket=bucket_name, Key=object_name)
|
117
|
-
# upload_id = mpu["UploadId"]
|
118
|
-
|
119
|
-
# file_size = file_size if file_size is not None else os.path.getsize(file_path)
|
120
|
-
|
121
|
-
# upload_info: UploadInfo = UploadInfo(
|
122
|
-
# s3_client=s3_client,
|
123
|
-
# bucket_name=bucket_name,
|
124
|
-
# object_name=object_name,
|
125
|
-
# src_file_path=file_path,
|
126
|
-
# upload_id=upload_id,
|
127
|
-
# retries=retries,
|
128
|
-
# chunk_size=chunk_size,
|
129
|
-
# file_size=file_size,
|
130
|
-
# )
|
131
|
-
# return upload_info
|
132
|
-
|
133
|
-
# class S3MultiPartUploader:
|
134
|
-
# def __init__(self, s3_client: BaseClient, verbose: bool) -> None:
|
135
|
-
# self.s3_client = s3_client
|
136
|
-
# self.verbose = verbose
|
137
|
-
|
138
|
-
# def prepare(self) -> UploadInfo:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|