|
8 | 8 | from .errors import FSError |
9 | 9 | from .opener import manage_fs |
10 | 10 | from .path import abspath, combine, frombase, normpath |
| 11 | +from .tools import is_thread_safe |
11 | 12 | from .walk import Walker |
12 | 13 |
|
13 | 14 | if False: # typing.TYPE_CHECKING |
@@ -287,7 +288,8 @@ def dst(): |
287 | 288 |
|
288 | 289 | with src() as _src_fs, dst() as _dst_fs: |
289 | 290 | with _src_fs.lock(), _dst_fs.lock(): |
290 | | - with Copier(num_workers=workers) as copier: |
| 291 | + _thread_safe = is_thread_safe(_src_fs, _dst_fs) |
| 292 | + with Copier(num_workers=workers if _thread_safe else 0) as copier: |
291 | 293 | _dst_fs.makedir(_dst_path, recreate=True) |
292 | 294 | for dir_path, dirs, files in walker.walk(_src_fs, _src_path): |
293 | 295 | copy_path = combine(_dst_path, frombase(_src_path, dir_path)) |
@@ -347,7 +349,8 @@ def dst(): |
347 | 349 |
|
348 | 350 | with src() as _src_fs, dst() as _dst_fs: |
349 | 351 | with _src_fs.lock(), _dst_fs.lock(): |
350 | | - with Copier(num_workers=workers) as copier: |
| 352 | + _thread_safe = is_thread_safe(_src_fs, _dst_fs) |
| 353 | + with Copier(num_workers=workers if _thread_safe else 0) as copier: |
351 | 354 | _dst_fs.makedir(_dst_path, recreate=True) |
352 | 355 | namespace = ("details", "modified") |
353 | 356 | dst_state = { |
|
0 commit comments