|
11 | 11 | from .base import FS |
12 | 12 | from .copy import copy_file, copy_dir |
13 | 13 | from .info import Info |
14 | | -from .move import move_file, move_dir |
15 | 14 | from .path import abspath, join, normpath |
16 | 15 | from .error_tools import unwrap_errors |
17 | 16 |
|
@@ -169,24 +168,21 @@ def makedir( |
169 | 168 |
|
170 | 169 | def move(self, src_path, dst_path, overwrite=False, preserve_time=False): |
171 | 170 | # 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) |
| 171 | + _fs, _src_path = self.delegate_path(src_path) |
| 172 | + _, _dst_path = self.delegate_path(dst_path) |
175 | 173 | 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) |
| 174 | + _fs.move( |
| 175 | + _src_path, _dst_path, overwrite=overwrite, preserve_time=preserve_time |
| 176 | + ) |
179 | 177 |
|
180 | 178 | def movedir(self, src_path, dst_path, create=False, preserve_time=False): |
181 | 179 | # 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) |
| 180 | + _fs, _src_path = self.delegate_path(src_path) |
| 181 | + _, _dst_path = self.delegate_path(dst_path) |
184 | 182 | 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) |
| 183 | + _fs.movedir( |
| 184 | + _src_path, _dst_path, create=create, preserve_time=preserve_time |
| 185 | + ) |
190 | 186 |
|
191 | 187 | def openbin(self, path, mode="r", buffering=-1, **options): |
192 | 188 | # type: (Text, Text, int, **Any) -> BinaryIO |
|
0 commit comments