From 3f6009bec00da677a4aede3ddb3966ebd7be28c1 Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Tue, 21 Dec 2021 14:00:37 +0100 Subject: [PATCH 1/3] Update `move` and `movedir` methods of `WrapFS` to use the delegate FS methods --- fs/wrapfs.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/fs/wrapfs.py b/fs/wrapfs.py index 00edd7af..c0273bb8 100644 --- a/fs/wrapfs.py +++ b/fs/wrapfs.py @@ -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 From f257c8c27612304db65b69427433b139b20b320f Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Tue, 21 Dec 2021 14:09:53 +0100 Subject: [PATCH 2/3] Update `CHANGELOG.md` with fix from #511 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab0d827c..df604fcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). resources, causing `MemoryFS.scandir` to use the old name. ([#510](https://github.com/PyFilesystem/pyfilesystem2/pull/510)). Closes [#509](https://github.com/PyFilesystem/pyfilesystem2/issues/509). +- Make `WrapFS.move` and `WrapFS.movedir` use the delegate FS methods instead + of `fs.move` functions, which was causing optimized implementation of + `movedir` to be always skipped. + ([#511](https://github.com/PyFilesystem/pyfilesystem2/pull/511)). ## [2.4.14] - 2021-11-16 From df3672618e02e080b78a1c6861a32544c7c85441 Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Tue, 21 Dec 2021 14:19:05 +0100 Subject: [PATCH 3/3] Remove unused imports in `fs.wrapfs` --- fs/wrapfs.py | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/wrapfs.py b/fs/wrapfs.py index c0273bb8..00984e72 100644 --- a/fs/wrapfs.py +++ b/fs/wrapfs.py @@ -11,7 +11,6 @@ from .base import FS from .copy import copy_file, copy_dir from .info import Info -from .move import move_file, move_dir from .path import abspath, join, normpath from .error_tools import unwrap_errors