rclone-api 1.3.22__py2.py3-none-any.whl → 1.3.24__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/rclone.py CHANGED
@@ -831,9 +831,9 @@ class Rclone:
831
831
  vfs_read_chunk_size_limit = chunk_size
832
832
  vfs_read_chunk_streams = read_threads
833
833
  vfs_disk_space_total_size = chunk_size
834
- assert (
835
- chunk_size.as_int() % vfs_read_chunk_size.as_int() == 0
836
- ), f"chunk_size {chunk_size} must be a multiple of vfs_read_chunk_size {vfs_read_chunk_size}"
834
+ # assert (
835
+ # chunk_size.as_int() % vfs_read_chunk_size.as_int() == 0
836
+ # ), f"chunk_size {chunk_size} must be a multiple of vfs_read_chunk_size {vfs_read_chunk_size}"
837
837
  other_args += ["--vfs-read-chunk-size", vfs_read_chunk_size.as_str()]
838
838
  other_args += [
839
839
  "--vfs-read-chunk-size-limit",
@@ -189,6 +189,8 @@ def file_chunker(
189
189
  )
190
190
  fut.add_done_callback(callback.on_complete)
191
191
  # wait until the queue_upload queue can accept the next chunk
192
+ qsize = queue_upload.qsize()
193
+ print(f"queue_upload_size: {qsize}")
192
194
  while queue_upload.full():
193
195
  time.sleep(0.1)
194
196
  except Exception as e:
@@ -25,7 +25,10 @@ _MIN_UPLOAD_CHUNK_SIZE = 5 * 1024 * 1024 # 5MB
25
25
 
26
26
 
27
27
  def upload_task(
28
- info: UploadInfo, chunk: FilePart, part_number: int, retries: int
28
+ info: UploadInfo,
29
+ chunk: FilePart,
30
+ part_number: int,
31
+ retries: int,
29
32
  ) -> FinishedPiece:
30
33
  file_or_err: Path | Exception = chunk.get_file()
31
34
  if isinstance(file_or_err, Exception):
@@ -139,6 +142,40 @@ def _abort_previous_upload(upload_state: UploadState) -> None:
139
142
  locked_print(f"Error aborting previous upload: {e}")
140
143
 
141
144
 
145
+ def upload_runner(
146
+ upload_state: UploadState,
147
+ upload_info: UploadInfo,
148
+ upload_threads: int,
149
+ queue_upload: Queue[FilePart | EndOfStream],
150
+ cancel_chunker_event: Event,
151
+ ) -> None:
152
+ with ThreadPoolExecutor(max_workers=upload_threads) as executor:
153
+ try:
154
+ while True:
155
+ file_chunk: FilePart | EndOfStream = queue_upload.get()
156
+ if isinstance(file_chunk, EndOfStream):
157
+ break
158
+
159
+ def task(upload_info=upload_info, file_chunk=file_chunk):
160
+ return handle_upload(upload_info, file_chunk)
161
+
162
+ fut = executor.submit(task)
163
+
164
+ def done_cb(fut=fut):
165
+ result = fut.result()
166
+ if isinstance(result, Exception):
167
+ warnings.warn(f"Error uploading part: {result}, skipping")
168
+ return
169
+ # upload_state.finished_parts.put(result)
170
+ upload_state.add_finished(result)
171
+
172
+ fut.add_done_callback(done_cb)
173
+ except Exception:
174
+ cancel_chunker_event.set()
175
+ executor.shutdown(wait=False, cancel_futures=True)
176
+ raise
177
+
178
+
142
179
  def upload_file_multipart(
143
180
  s3_client: BaseClient,
144
181
  chunk_fetcher: Callable[[int, int, Any], Future[FilePart]],
@@ -265,32 +302,13 @@ def upload_file_multipart(
265
302
  try:
266
303
  thread_chunker = Thread(target=chunker_task, daemon=True)
267
304
  thread_chunker.start()
268
-
269
- with ThreadPoolExecutor(max_workers=upload_threads) as executor:
270
- try:
271
- while True:
272
- file_chunk: FilePart | EndOfStream = queue_upload.get()
273
- if isinstance(file_chunk, EndOfStream):
274
- break
275
-
276
- def task(upload_info=upload_info, file_chunk=file_chunk):
277
- return handle_upload(upload_info, file_chunk)
278
-
279
- fut = executor.submit(task)
280
-
281
- def done_cb(fut=fut):
282
- result = fut.result()
283
- if isinstance(result, Exception):
284
- warnings.warn(f"Error uploading part: {result}, skipping")
285
- return
286
- # upload_state.finished_parts.put(result)
287
- upload_state.add_finished(result)
288
-
289
- fut.add_done_callback(done_cb)
290
- except Exception:
291
- cancel_chunker_event.set()
292
- executor.shutdown(wait=False, cancel_futures=True)
293
- raise
305
+ upload_runner(
306
+ upload_state=upload_state,
307
+ upload_info=upload_info,
308
+ upload_threads=upload_threads,
309
+ queue_upload=queue_upload,
310
+ cancel_chunker_event=cancel_chunker_event,
311
+ )
294
312
  # upload_state.finished_parts.put(None) # Signal the end of the queue
295
313
  upload_state.add_finished(EndOfStream())
296
314
  thread_chunker.join()
rclone_api/types.py CHANGED
@@ -299,6 +299,7 @@ class FilePart:
299
299
  self.payload = payload
300
300
  return
301
301
  if isinstance(payload, bytes):
302
+ print(f"Creating file part with payload: {len(payload)}")
302
303
  self.payload = get_chunk_tmpdir() / f"{random_str(12)}.chunk"
303
304
  with _TMP_DIR_ACCESS_LOCK:
304
305
  if not self.payload.parent.exists():
@@ -306,7 +307,9 @@ class FilePart:
306
307
  self.payload.write_bytes(payload)
307
308
  _add_for_cleanup(self.payload)
308
309
  if isinstance(payload, Path):
310
+ print("Adopting payload: ", payload)
309
311
  self.payload = payload
312
+ _add_for_cleanup(self.payload)
310
313
 
311
314
  def get_file(self) -> Path | Exception:
312
315
  return self.payload
@@ -344,18 +347,26 @@ class FilePart:
344
347
  return isinstance(self.payload, Exception)
345
348
 
346
349
  def dispose(self) -> None:
350
+ print("Disposing file part")
347
351
  with self._lock:
348
352
  if isinstance(self.payload, Exception):
349
353
  warnings.warn(
350
354
  f"Cannot close file part because the payload represents an error: {self.payload}"
351
355
  )
356
+ print("Cannot close file part because the payload represents an error")
352
357
  return
353
358
  if self.payload.exists():
359
+ print(f"File part {self.payload} exists")
354
360
  try:
361
+ print(f"Unlinking file part {self.payload}")
355
362
  self.payload.unlink()
356
363
  print(f"File part {self.payload} deleted")
357
364
  except Exception as e:
358
365
  warnings.warn(f"Cannot close file part because of error: {e}")
366
+ else:
367
+ warnings.warn(
368
+ f"Cannot close file part because it does not exist: {self.payload}"
369
+ )
359
370
 
360
371
  def __del__(self):
361
372
  self.dispose()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rclone_api
3
- Version: 1.3.22
3
+ Version: 1.3.24
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  License: BSD 3-Clause License
@@ -17,11 +17,11 @@ rclone_api/log.py,sha256=VZHM7pNSXip2ZLBKMP7M1u-rp_F7zoafFDuR8CPUoKI,1271
17
17
  rclone_api/mount.py,sha256=TE_VIBMW7J1UkF_6HRCt8oi_jGdMov4S51bm2OgxFAM,10045
18
18
  rclone_api/mount_read_chunker.py,sha256=7jaF1Rsjr-kXIZW--Ol1QuG7WArBgdIcpQ0AJMYn7bI,4764
19
19
  rclone_api/process.py,sha256=BGXJTZVT__jeaDyjN8_kRycliOhkBErMPdHO1hKRvJE,5271
20
- rclone_api/rclone.py,sha256=JYSilA0cFn6UQ0_72kqWgNhGyIAOqhbTilrbZkRnfXs,54111
20
+ rclone_api/rclone.py,sha256=yRhQoCBJI-tfhxySR17a-vSEhWw5cMbk8_WbYs5WqRc,54117
21
21
  rclone_api/remote.py,sha256=jq3dPbAGvYZFW5cTviqxT2w6_jG2LLfS1RIcYSmMsQQ,503
22
22
  rclone_api/rpath.py,sha256=8ZA_1wxWtskwcy0I8V2VbjKDmzPkiWd8Q2JQSvh-sYE,2586
23
23
  rclone_api/scan_missing_folders.py,sha256=Kulca2Q6WZodt00ATFHkmqqInuoPvBkhTcS9703y6po,4740
24
- rclone_api/types.py,sha256=aj3usJrIDKC4MKuObBo9WjlR1isyJColdOQWXo3Repo,10608
24
+ rclone_api/types.py,sha256=CGwxlnhVgJumwSLukx68ZEM9m2gxLPDcAeVLbzS2JBA,11173
25
25
  rclone_api/util.py,sha256=F9Q3zbWRsgPF4NG6OWB63cZ7GVq82lsraP47gmmDohU,5416
26
26
  rclone_api/walk.py,sha256=-54NVE8EJcCstwDoaC_UtHm73R2HrZwVwQmsnv55xNU,3369
27
27
  rclone_api/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
@@ -37,14 +37,14 @@ rclone_api/experimental/flags_base.py,sha256=ajU_czkTcAxXYU-SlmiCfHY7aCQGHvpCLqJ
37
37
  rclone_api/profile/mount_copy_bytes.py,sha256=M1vZn-Mrga14Ik7MHGZHbnwYli41Ep6Tyll7hQc7Wmo,9071
38
38
  rclone_api/s3/api.py,sha256=PafsIEyWDpLWAXsZAjFm9CY14vJpsDr9lOsn0kGRLZ0,4009
39
39
  rclone_api/s3/basic_ops.py,sha256=hK3366xhVEzEcjz9Gk_8lFx6MRceAk72cax6mUrr6ko,2104
40
- rclone_api/s3/chunk_task.py,sha256=kA6_5fLNdtT3QdTFrfBY6y8sH9Og8nM2mrjgAz_g1Rc,7196
40
+ rclone_api/s3/chunk_task.py,sha256=ZAsVOdiKae0aJ6_YjDuFYG8ZxCfF5jWWMToPM_Li9bo,7286
41
41
  rclone_api/s3/chunk_types.py,sha256=oSWv8No9V3BeM7IcGnowyR2a7YrszdAXzEJlxaeZcp0,8852
42
42
  rclone_api/s3/create.py,sha256=wgfkapv_j904CfKuWyiBIWJVxfAx_ftemFSUV14aT68,3149
43
43
  rclone_api/s3/types.py,sha256=Elmh__gvZJyJyElYwMmvYZIBIunDJiTRAbEg21GmsRU,1604
44
- rclone_api/s3/upload_file_multipart.py,sha256=UlrUl8fB0oK8_r0w8ZwH79jlOCHQrMOKWZeNCmHrT7M,12052
45
- rclone_api-1.3.22.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
46
- rclone_api-1.3.22.dist-info/METADATA,sha256=jf9TZCxwZIaOD_4bqJQ_SrVJxygQS2fqlBuEHj0tEGc,4628
47
- rclone_api-1.3.22.dist-info/WHEEL,sha256=rF4EZyR2XVS6irmOHQIJx2SUqXLZKRMUrjsg8UwN-XQ,109
48
- rclone_api-1.3.22.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
49
- rclone_api-1.3.22.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
50
- rclone_api-1.3.22.dist-info/RECORD,,
44
+ rclone_api/s3/upload_file_multipart.py,sha256=bxAB_SFkyydBBzC_cAv7gShe93nBkFVS-TXwM2Xttfk,12425
45
+ rclone_api-1.3.24.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
46
+ rclone_api-1.3.24.dist-info/METADATA,sha256=uP9r1gJ4ASyiISJg48vY86hiUBlvib2ZRRhJ_tBaSyg,4628
47
+ rclone_api-1.3.24.dist-info/WHEEL,sha256=rF4EZyR2XVS6irmOHQIJx2SUqXLZKRMUrjsg8UwN-XQ,109
48
+ rclone_api-1.3.24.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
49
+ rclone_api-1.3.24.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
50
+ rclone_api-1.3.24.dist-info/RECORD,,