mar10 / pyftpsync

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

Upload synchronize except where local file has been deleted? #27

Closed SeanDS closed 6 years ago

SeanDS commented 6 years ago

I'm using v2.0.0 to sync files from one computer to an FTP server. Only a history of the last 7 files are kept on the local computer: I have a script that periodically deletes anything older than 7 days. I've found that UploadSynchronizer deletes the file on the remote FTP server after the local copy is deleted, which is not the behaviour I want. I'd like to sync local files to the FTP server, but not have to keep the full archive of files on the local computer.

I'm currently using options:

        upload_opts = {"force": True,
                       "resolve": "local",
                       "verbose": 3}

I think this is because pyftpsync keeps track of files it's seen before, and when it no longer sees the local file I delete, it also deletes it on the remote.

Is there some way to turn off this behaviour? I looked around the code and couldn't see a way - it seems that it's hard-coded in the operations map in resources.py?

mar10 commented 6 years ago

Maybe the meaning of the --delete option should be extended to cover this case as well. Currently it is only applied to files that where missing before, but not for files where a delete operation was detected.

--delete              remove remote files if they don't exist locally

This would mean that without this flag, no files would ever get deleted on remote. Not sure yet.

SeanDS commented 6 years ago

Maybe when --delete is set to false, nothing should ever get deleted, and add e.g. --delete-remote to replicate existing behaviour?

I might patch this for the moment to avoid my files being deleted, but could you give me an idea of if/when this might appear in an updated version? Thanks for the hard work that went into this library!

mar10 commented 6 years ago

'If': The change will probably go into the next minor release, one way or the other. 'When': I can't spend much time on this project at the moment, so I can't give you an ETA right now, sorry.

SeanDS commented 6 years ago

No worries, thanks for the update.