rclone-api 1.2.7__py2.py3-none-any.whl → 1.2.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/mount.py CHANGED
@@ -288,6 +288,32 @@ def _cache_dir_delete_on_exit(cache_dir: Path) -> None:
288
288
  warnings.warn(f"Error removing cache directory {cache_dir}: {e}")
289
289
 
290
290
 
291
+ def _read_from_mount_task(
292
+ offset: int, size: int, path: Path, verbose: bool
293
+ ) -> bytes | Exception:
294
+ if verbose or True:
295
+ print(f"Fetching chunk: offset={offset}, size={size}, path={path}")
296
+ try:
297
+ with path.open("rb") as f:
298
+ f.seek(offset)
299
+ sz = f.read(size)
300
+ assert len(sz) == size, f"Invalid read size: {len(sz)}"
301
+ return sz
302
+ except KeyboardInterrupt as e:
303
+ import _thread
304
+
305
+ warnings.warn(f"Error fetching file chunk: {e}")
306
+
307
+ _thread.interrupt_main()
308
+ return Exception(e)
309
+ except Exception as e:
310
+ stack_trace = traceback.format_exc()
311
+ warnings.warn(
312
+ f"Error fetching file chunk at offset {offset} + {size}: {e}\n{stack_trace}"
313
+ )
314
+ return e
315
+
316
+
291
317
  class MultiMountFileChunker:
292
318
  def __init__(
293
319
  self,
@@ -335,36 +361,16 @@ class MultiMountFileChunker:
335
361
  path = mount.mount_path / self.filename
336
362
 
337
363
  def task(
338
- offset=offset, size=size, path=path, mount=mount
364
+ offset=offset, size=size, path=path, mount=mount, verbose=self.verbose
339
365
  ) -> bytes | Exception:
340
- if self.verbose or True:
341
- print(f"Fetching chunk: offset={offset}, size={size}, path={path}")
342
- try:
343
- if offset + size > self.filesize:
344
- raise ValueError(f"Invalid offset + size: {offset + size}")
345
- with path.open("rb") as f:
346
- f.seek(offset)
347
- sz = f.read(size)
348
- assert len(sz) == size, f"Invalid read size: {len(sz)}"
349
- return sz
350
- except KeyboardInterrupt as e:
351
- import _thread
352
-
353
- warnings.warn(f"Error fetching file chunk: {e}")
354
-
355
- _thread.interrupt_main()
356
- return Exception(e)
357
- except Exception as e:
358
- stack_trace = traceback.format_exc()
359
- warnings.warn(
360
- f"Error fetching file chunk at offset {offset} + {size}: {e}\n{stack_trace}"
361
- )
362
- return e
363
- finally:
364
- with self.lock:
365
- self.mounts_processing.remove(mount)
366
- self.mounts_availabe.append(mount)
367
- self.semaphore.release()
366
+ out = _read_from_mount_task(
367
+ offset=offset, size=size, path=path, verbose=verbose
368
+ )
369
+ with self.lock:
370
+ self.mounts_processing.remove(mount)
371
+ self.mounts_availabe.append(mount)
372
+ self.semaphore.release()
373
+ return out
368
374
 
369
375
  fut = self.executor.submit(task)
370
376
  return fut
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rclone_api
3
- Version: 1.2.7
3
+ Version: 1.2.8
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  License: BSD 3-Clause License
@@ -11,7 +11,7 @@ rclone_api/exec.py,sha256=Pd7pUBd8ib5MzqvMybG2DQISPRbDRu20VjVRL2mLAVY,1076
11
11
  rclone_api/file.py,sha256=EP5yT2dZ0H2p7CY5n0y5k5pHhIliV25pm8KOwBklUTk,1863
12
12
  rclone_api/filelist.py,sha256=xbiusvNgaB_b_kQOZoHMJJxn6TWGtPrWd2J042BI28o,767
13
13
  rclone_api/group_files.py,sha256=H92xPW9lQnbNw5KbtZCl00bD6iRh9yRbCuxku4j_3dg,8036
14
- rclone_api/mount.py,sha256=bnujsYZ0uNvIovfgkvoCyz0qZ71GHIcqfVbjESNMgGI,13375
14
+ rclone_api/mount.py,sha256=qdfPatPKGAAaNexJQCvunq_MdBJL6NSlGmin8cHCXGg,13255
15
15
  rclone_api/process.py,sha256=rBj_S86jC6nqCYop-jq8r9eMSteKeObxUrJMgH8LZvI,5084
16
16
  rclone_api/rclone.py,sha256=V4oeepsleic2llCA7JekMw1iOwN7uYE3ktJ-gEA7wcw,49277
17
17
  rclone_api/remote.py,sha256=O9WDUFQy9f6oT1HdUbTixK2eg0xtBBm8k4Xl6aa6K00,431
@@ -33,9 +33,9 @@ rclone_api/s3/chunk_types.py,sha256=2n9U1BZ_5mcpoLLbSqkhvzgKj814jtSMnih9CWKcChU,
33
33
  rclone_api/s3/create.py,sha256=wgfkapv_j904CfKuWyiBIWJVxfAx_ftemFSUV14aT68,3149
34
34
  rclone_api/s3/types.py,sha256=ZUw9s164wljCEMTS4CoHXNzFIhYJEgKD6NDAu-RXyr8,1551
35
35
  rclone_api/s3/upload_file_multipart.py,sha256=aDaLF2FWSvU_jurxiFphGZBncvkPqWN47VFNzYSSTWM,10906
36
- rclone_api-1.2.7.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
37
- rclone_api-1.2.7.dist-info/METADATA,sha256=P6YPH1dHv2MVivIFK7NJqhErXVikuans9oR7kX1Pn4Q,4536
38
- rclone_api-1.2.7.dist-info/WHEEL,sha256=rF4EZyR2XVS6irmOHQIJx2SUqXLZKRMUrjsg8UwN-XQ,109
39
- rclone_api-1.2.7.dist-info/entry_points.txt,sha256=TV8kwP3FRzYwUEr0RLC7aJh0W03SAefIJNXTJ-FdMIQ,200
40
- rclone_api-1.2.7.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
41
- rclone_api-1.2.7.dist-info/RECORD,,
36
+ rclone_api-1.2.8.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
37
+ rclone_api-1.2.8.dist-info/METADATA,sha256=eWhq_lLs9m_Vp01kxODo85kaTye0kNaizIDMFXeIlmY,4536
38
+ rclone_api-1.2.8.dist-info/WHEEL,sha256=rF4EZyR2XVS6irmOHQIJx2SUqXLZKRMUrjsg8UwN-XQ,109
39
+ rclone_api-1.2.8.dist-info/entry_points.txt,sha256=TV8kwP3FRzYwUEr0RLC7aJh0W03SAefIJNXTJ-FdMIQ,200
40
+ rclone_api-1.2.8.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
41
+ rclone_api-1.2.8.dist-info/RECORD,,