Skip to content

Commit 3bc8691

Browse files
committed
use validatepath
1 parent 9d9dcd6 commit 3bc8691

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

fs/base.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,17 +1171,19 @@ def move(self, src_path, dst_path, overwrite=False, preserve_time=False):
11711171
``dst_path`` does not exist.
11721172
11731173
"""
1174-
if not overwrite and self.exists(dst_path):
1174+
_src_path = self.validatepath(src_path)
1175+
_dst_path = self.validatepath(dst_path)
1176+
if not overwrite and self.exists(_dst_path):
11751177
raise errors.DestinationExists(dst_path)
1176-
if self.getinfo(src_path).is_dir:
1178+
if self.getinfo(_src_path).is_dir:
11771179
raise errors.FileExpected(src_path)
1178-
if normpath(src_path) == normpath(dst_path):
1180+
if _src_path == _dst_path:
11791181
# early exit when moving a file onto itself
11801182
return
11811183
if self.getmeta().get("supports_rename", False):
11821184
try:
1183-
src_sys_path = self.getsyspath(src_path)
1184-
dst_sys_path = self.getsyspath(dst_path)
1185+
src_sys_path = self.getsyspath(_src_path)
1186+
dst_sys_path = self.getsyspath(_dst_path)
11851187
except errors.NoSysPath: # pragma: no cover
11861188
pass
11871189
else:
@@ -1191,15 +1193,15 @@ def move(self, src_path, dst_path, overwrite=False, preserve_time=False):
11911193
pass
11921194
else:
11931195
if preserve_time:
1194-
copy_modified_time(self, src_path, self, dst_path)
1196+
copy_modified_time(self, _src_path, self, _dst_path)
11951197
return
11961198
with self._lock:
1197-
with self.open(src_path, "rb") as read_file:
1199+
with self.open(_src_path, "rb") as read_file:
11981200
# FIXME(@althonos): typing complains because open return IO
1199-
self.upload(dst_path, read_file) # type: ignore
1201+
self.upload(_dst_path, read_file) # type: ignore
12001202
if preserve_time:
1201-
copy_modified_time(self, src_path, self, dst_path)
1202-
self.remove(src_path)
1203+
copy_modified_time(self, _src_path, self, _dst_path)
1204+
self.remove(_src_path)
12031205

12041206
def open(
12051207
self,

fs/copy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ def copy_structure(
306306
dst_root (str): Path to the target root of the tree structure.
307307
308308
"""
309-
_src_root = abspath(normpath(src_root))
310-
_dst_root = abspath(normpath(dst_root))
309+
_src_root = src_fs.validatepath(src_root)
310+
_dst_root = dst_fs.validatepath(dst_root)
311311
# It's not allowed to copy a structure into itself
312312
if src_fs == dst_fs and isbase(_src_root, _dst_root):
313313
raise IllegalDestination(dst_root)

0 commit comments

Comments
 (0)