Skip to content

Commit 3f6009b

Browse files
committed
Update move and movedir methods of WrapFS to use the delegate FS methods
1 parent a6ea045 commit 3f6009b

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

fs/wrapfs.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,24 +169,21 @@ def makedir(
169169

170170
def move(self, src_path, dst_path, overwrite=False, preserve_time=False):
171171
# type: (Text, Text, bool, bool) -> None
172-
# A custom move permits a potentially optimized code path
173-
src_fs, _src_path = self.delegate_path(src_path)
174-
dst_fs, _dst_path = self.delegate_path(dst_path)
172+
_fs, _src_path = self.delegate_path(src_path)
173+
_, _dst_path = self.delegate_path(dst_path)
175174
with unwrap_errors({_src_path: src_path, _dst_path: dst_path}):
176-
if not overwrite and dst_fs.exists(_dst_path):
177-
raise errors.DestinationExists(_dst_path)
178-
move_file(src_fs, _src_path, dst_fs, _dst_path, preserve_time=preserve_time)
175+
_fs.move(
176+
_src_path, _dst_path, overwrite=overwrite, preserve_time=preserve_time
177+
)
179178

180179
def movedir(self, src_path, dst_path, create=False, preserve_time=False):
181180
# type: (Text, Text, bool, bool) -> None
182-
src_fs, _src_path = self.delegate_path(src_path)
183-
dst_fs, _dst_path = self.delegate_path(dst_path)
181+
_fs, _src_path = self.delegate_path(src_path)
182+
_, _dst_path = self.delegate_path(dst_path)
184183
with unwrap_errors({_src_path: src_path, _dst_path: dst_path}):
185-
if not create and not dst_fs.exists(_dst_path):
186-
raise errors.ResourceNotFound(dst_path)
187-
if not src_fs.getinfo(_src_path).is_dir:
188-
raise errors.DirectoryExpected(src_path)
189-
move_dir(src_fs, _src_path, dst_fs, _dst_path, preserve_time=preserve_time)
184+
_fs.movedir(
185+
_src_path, _dst_path, create=create, preserve_time=preserve_time
186+
)
190187

191188
def openbin(self, path, mode="r", buffering=-1, **options):
192189
# type: (Text, Text, int, **Any) -> BinaryIO

0 commit comments

Comments
 (0)