Skip to content

Commit da62be4

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

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

fs/wrapfs.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,24 +169,17 @@ 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
173172
src_fs, _src_path = self.delegate_path(src_path)
174-
dst_fs, _dst_path = self.delegate_path(dst_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(_src_path, _dst_path, create=create, preserve_time=preserve_time)
179176

180177
def movedir(self, src_path, dst_path, create=False, preserve_time=False):
181178
# 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)
179+
_fs, _src_path = self.delegate_path(src_path)
180+
_, _dst_path = self.delegate_path(dst_path)
184181
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)
182+
_fs.movedir(_src_path, _dst_path, create=create, preserve_time=preserve_time)
190183

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

0 commit comments

Comments
 (0)