rclone-api 1.5.9__py3-none-any.whl → 1.5.10__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_util.py CHANGED
@@ -157,6 +157,35 @@ def wait_for_mount(
157
157
  raise last_error
158
158
 
159
159
 
160
+ def _rmtree_ignore_mounts(path):
161
+ """
162
+ Recursively remove a directory tree while ignoring mount points.
163
+
164
+ Directories that are mount points (where os.path.ismount returns True)
165
+ are skipped.
166
+ """
167
+ # Iterate over directory entries without following symlinks
168
+ with os.scandir(path) as it:
169
+ for entry in it:
170
+ full_path = entry.path
171
+ if entry.is_dir(follow_symlinks=False):
172
+ # If it's a mount point, skip recursing into it
173
+ if os.path.ismount(full_path):
174
+ print(f"Skipping mount point: {full_path}")
175
+ continue
176
+ # Recursively remove subdirectories
177
+ _rmtree_ignore_mounts(full_path)
178
+ else:
179
+ # Remove files or symlinks
180
+ os.unlink(full_path)
181
+ # Remove the now-empty directory
182
+ os.rmdir(path)
183
+
184
+
185
+ # Example usage:
186
+ # rmtree_ignore_mounts("/path/to/directory")
187
+
188
+
160
189
  def clean_mount(mount: Mount | Path, verbose: bool = False, wait=True) -> None:
161
190
  """
162
191
  Clean up a mount path across Linux, macOS, and Windows.
@@ -209,7 +238,9 @@ def clean_mount(mount: Mount | Path, verbose: bool = False, wait=True) -> None:
209
238
  _run_command(f"mountvol {mount_path} /D", verbose)
210
239
  # If that does not work, try to remove the directory directly.
211
240
  try:
212
- mount_path.rmdir()
241
+ _rmtree_ignore_mounts(mount_path)
242
+ if mount_path.exists():
243
+ raise OSError(f"Failed to remove mount directory {mount_path}")
213
244
  if verbose:
214
245
  print(f"Successfully removed mount directory {mount_path}")
215
246
  except Exception:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rclone_api
3
- Version: 1.5.9
3
+ Version: 1.5.10
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  License: BSD 3-Clause License
@@ -18,7 +18,7 @@ rclone_api/http_server.py,sha256=LhovQu2AI-Z7zQIWflWelCiCDLnWzisL32Rs5350kxE,885
18
18
  rclone_api/install.py,sha256=Xb1BRn8rQcSpSd4dzmvIOELP2zM2DytUeIZ6jzv738A,2893
19
19
  rclone_api/log.py,sha256=VZHM7pNSXip2ZLBKMP7M1u-rp_F7zoafFDuR8CPUoKI,1271
20
20
  rclone_api/mount.py,sha256=LZqEhuKZunbWVqmsOIqkkCotaxWJpdFRS1InXveoU5E,1428
21
- rclone_api/mount_util.py,sha256=7Ky2KXG3YbxftQU8R1DnDzo3hcBpvSmwTPsd0ezHy5g,9058
21
+ rclone_api/mount_util.py,sha256=OCc3XDyo7jx7ZDvW4UtH0BYUd6vF9kFRUgcSTI9W7Qs,10134
22
22
  rclone_api/process.py,sha256=tGooS5NLdPuqHh7hCH8SfK44A6LGftPQCPQUNgSo0a0,5714
23
23
  rclone_api/rclone_impl.py,sha256=kr0gvOSuiwxU15rvATYZmSzpWYDiAzjZ2WNe1wqI6NM,46345
24
24
  rclone_api/remote.py,sha256=mTgMTQTwxUmbLjTpr-AGTId2ycXKI9mLX5L7PPpDIoc,520
@@ -53,9 +53,9 @@ rclone_api/s3/multipart/upload_parts_inline.py,sha256=V7syKjFyVIe4U9Ahl5XgqVTzt9
53
53
  rclone_api/s3/multipart/upload_parts_resumable.py,sha256=diJoUpVYow6No_dNgOZIYVsv43k4evb6zixqpzWJaUk,9771
54
54
  rclone_api/s3/multipart/upload_parts_server_side_merge.py,sha256=Fp2pdrs5dONQI9LkfNolgAGj1-Z2V1SsRd0r0sreuXI,18040
55
55
  rclone_api/s3/multipart/upload_state.py,sha256=f-Aq2NqtAaMUMhYitlICSNIxCKurWAl2gDEUVizLIqw,6019
56
- rclone_api-1.5.9.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
57
- rclone_api-1.5.9.dist-info/METADATA,sha256=KDWkgAnwAVHj0GGPDKosvVJrxoJbJW92zYnmIuwPjGQ,32633
58
- rclone_api-1.5.9.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
59
- rclone_api-1.5.9.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
60
- rclone_api-1.5.9.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
61
- rclone_api-1.5.9.dist-info/RECORD,,
56
+ rclone_api-1.5.10.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
57
+ rclone_api-1.5.10.dist-info/METADATA,sha256=L_UinKq8TqZwIr24SdXgm9eNgnjHMROmAFABLamsqJw,32634
58
+ rclone_api-1.5.10.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
59
+ rclone_api-1.5.10.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
60
+ rclone_api-1.5.10.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
61
+ rclone_api-1.5.10.dist-info/RECORD,,