Skip to content

Commit

Permalink
Update move and movedir methods of WrapFS to use the delegate F…
Browse files Browse the repository at this point in the history
…S methods
  • Loading branch information
althonos committed Dec 21, 2021
1 parent a6ea045 commit 3f6009b
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions fs/wrapfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,24 +169,21 @@ def makedir(

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

def movedir(self, src_path, dst_path, create=False, preserve_time=False):
# type: (Text, Text, bool, bool) -> None
src_fs, _src_path = self.delegate_path(src_path)
dst_fs, _dst_path = self.delegate_path(dst_path)
_fs, _src_path = self.delegate_path(src_path)
_, _dst_path = self.delegate_path(dst_path)
with unwrap_errors({_src_path: src_path, _dst_path: dst_path}):
if not create and not dst_fs.exists(_dst_path):
raise errors.ResourceNotFound(dst_path)
if not src_fs.getinfo(_src_path).is_dir:
raise errors.DirectoryExpected(src_path)
move_dir(src_fs, _src_path, dst_fs, _dst_path, preserve_time=preserve_time)
_fs.movedir(
_src_path, _dst_path, create=create, preserve_time=preserve_time
)

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

0 comments on commit 3f6009b

Please sign in to comment.