Skip to content

Commit 420998d

Browse files
committed
copy_structure FS can be of type str
1 parent 3bc8691 commit 420998d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

fs/copy.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,16 @@ def copy_structure(
306306
dst_root (str): Path to the target root of the tree structure.
307307
308308
"""
309-
_src_root = src_fs.validatepath(src_root)
310-
_dst_root = dst_fs.validatepath(dst_root)
311-
# It's not allowed to copy a structure into itself
312-
if src_fs == dst_fs and isbase(_src_root, _dst_root):
313-
raise IllegalDestination(dst_root)
314309
walker = walker or Walker()
315310
with manage_fs(src_fs) as _src_fs:
316311
with manage_fs(dst_fs, create=True) as _dst_fs:
312+
_src_root = _src_fs.validatepath(src_root)
313+
_dst_root = _dst_fs.validatepath(dst_root)
314+
315+
# It's not allowed to copy a structure into itself
316+
if _src_fs == _dst_fs and isbase(_src_root, _dst_root):
317+
raise IllegalDestination(dst_root)
318+
317319
with _src_fs.lock(), _dst_fs.lock():
318320
_dst_fs.makedirs(_dst_root, recreate=True)
319321
for dir_path in walker.dirs(_src_fs, _src_root):

0 commit comments

Comments
 (0)