mar10 / pyftpsync

Synchronize directories using FTP(S), SFTP, or file system access.
https://pyftpsync.readthedocs.io
MIT License
117 stars 25 forks source link

DownloadSynchronizer delete local files, when the 'delete' option is False #33

Closed yyzeric closed 6 years ago

yyzeric commented 6 years ago

I used DownloadSynchronizer to download files from one remote ftp server. And when the files in the remote server was deleted, I found the DownloadSynchronizer would also delete the same local files. My opts is : opts = {"resolve": "skip", "verbose": 3,"delete" : False }. In order to avoid this issue, I just deleted 'pair.override_operation("delete_local", "restore")' under DownloadSynchronizer.re_classify_pair. Is this a bug or my opts has problem? Please kindly advice this. Thanks.

mar10 commented 6 years ago

Thanks for reporting. This is a known issue, see #27

However, I don't quite understand, why your fix helps. if delete: should be False in your case?

        if delete:
            if classification == ("new", "missing"):
                assert pair.operation == "copy_local"
                pair.override_operation("delete_local", "restore")
                # return
yyzeric commented 6 years ago

I also have no idea about this. From my understanding, if delete supposes to be False in my case, and the local file would not be delete. But I cannot find any other function under DownloadSynchronizer can delete the local file. So I just delete the possible one.