Skip to content

Commit b4b3478

Browse files
author
atollk
committed
Fixed the newly added preserve_time parameter in fs.copy actually being used, rather than being assumed to be True always.
1 parent 09cf4dc commit b4b3478

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

fs/copy.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ def copy_fs(
4545
4646
"""
4747
return copy_dir(
48-
src_fs, "/", dst_fs, "/", walker=walker, on_copy=on_copy, workers=workers
48+
src_fs,
49+
"/",
50+
dst_fs,
51+
"/",
52+
walker=walker,
53+
on_copy=on_copy,
54+
workers=workers,
55+
preserve_time=preserve_time,
4956
)
5057

5158

@@ -199,7 +206,8 @@ def copy_file_internal(
199206
with src_fs.openbin(src_path) as read_file:
200207
dst_fs.upload(dst_path, read_file)
201208

202-
copy_mtime(src_fs, src_path, dst_fs, dst_path)
209+
if preserve_time:
210+
copy_mtime(src_fs, src_path, dst_fs, dst_path)
203211

204212

205213
def copy_file_if_newer(
@@ -262,7 +270,6 @@ def copy_structure(
262270
src_fs, # type: Union[FS, Text]
263271
dst_fs, # type: Union[FS, Text]
264272
walker=None, # type: Optional[Walker]
265-
preserve_time=False, # type: bool
266273
):
267274
# type: (...) -> None
268275
"""Copy directories (but not files) from ``src_fs`` to ``dst_fs``.
@@ -273,8 +280,6 @@ def copy_structure(
273280
walker (~fs.walk.Walker, optional): A walker object that will be
274281
used to scan for files in ``src_fs``. Set this if you only
275282
want to consider a sub-set of the resources in ``src_fs``.
276-
preserve_time (bool): If `True`, try to preserve mtime of the
277-
resource (defaults to `False`).
278283
279284
"""
280285
walker = walker or Walker()

tests/test_move.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_move_fs(self):
2121
src_file2_info = src_fs.getinfo("foo/bar/baz.txt", namespaces)
2222

2323
dst_fs = open_fs("mem://")
24-
fs.move.move_fs(src_fs, dst_fs)
24+
fs.move.move_fs(src_fs, dst_fs, preserve_time=self.preserve_time)
2525

2626
self.assertTrue(dst_fs.isdir("foo/bar"))
2727
self.assertTrue(dst_fs.isfile("test.txt"))
@@ -44,7 +44,7 @@ def test_move_dir(self):
4444
src_file2_info = src_fs.getinfo("foo/bar/baz.txt", namespaces)
4545

4646
dst_fs = open_fs("mem://")
47-
fs.move.move_dir(src_fs, "/foo", dst_fs, "/")
47+
fs.move.move_dir(src_fs, "/foo", dst_fs, "/", preserve_time=self.preserve_time)
4848

4949
self.assertTrue(dst_fs.isdir("bar"))
5050
self.assertTrue(dst_fs.isfile("bar/baz.txt"))

0 commit comments

Comments
 (0)