PyFilesystem / s3fs

Amazon S3 filesystem for PyFilesystem2
http://fs-s3fs.readthedocs.io/en/latest/
MIT License
153 stars 55 forks source link

copydir fails with TypeError: copy() got an unexpected keyword argument 'preserve_time' #90

Open iljau opened 2 years ago

iljau commented 2 years ago
import fs
import fs_s3fs
from fs import open_fs
from fs_s3fs import S3FS

def copy_to_latest():
    print(f"{fs.__version__=}")
    print(f"{fs_s3fs.__version__=}")

    target_fs: S3FS = open_fs(f's3://my-bucket/some/path/')
    print(f"{target_fs=}")

    src_path = "2022-06-27/08:05:10/"
    print(f"{src_path=}")

    dst_path = "latest"
    print(f"{dst_path=}")

    target_fs.copydir(
        src_path=src_path,
        dst_path=dst_path,
        create=True,
    )

if __name__ == "__main__":
    copy_to_latest()
fs.__version__='2.4.16'
fs_s3fs.__version__='1.1.1'
target_fs=[..]
src_path='2022-06-27/08:05:10/'
dst_path='latest'
Traceback (most recent call last):
  File "/[..]/copydir_bug.py", line 28, in <module>
    copy_to_latest()
  File "/[..]/copydir_bug.py", line 20, in copy_to_latest
    target_fs.copydir(
  File "/opt/venv/lib/python3.8/site-packages/fs/base.py", line 464, in copydir
    copy.copy_dir(self, src_path, self, dst_path, preserve_time=preserve_time)
  File "/opt/venv/lib/python3.8/site-packages/fs/copy.py", line 346, in copy_dir
    copy_dir_if(
  File "/opt/venv/lib/python3.8/site-packages/fs/copy.py", line 450, in copy_dir_if
    copier.copy(_src_fs, dir_path, _dst_fs, copy_path)
  File "/opt/venv/lib/python3.8/site-packages/fs/_bulk.py", line 144, in copy
    copy_file_internal(
  File "/opt/venv/lib/python3.8/site-packages/fs/copy.py", line 263, in copy_file_internal
    src_fs.copy(src_path, dst_path, overwrite=True, preserve_time=preserve_time)
TypeError: copy() got an unexpected keyword argument 'preserve_time'
i18n-tribe commented 10 months ago

I've submitted a PR to fix this issue.

Anyone who needs to work around this issue before my PR is merged can install fs-s3fs from my branch.

E.g. if you're using pipenv you can add a line like this in your Pipfile:

fs-s3fs = {git = "https://github.com/i18n-tribe/s3fs.git", ref = "make_copydir_work_again---fixes_issue-90"}