Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
sftp.rename doesn't behave like OpenSSH's rename #1012
I'm not sure if this is a bug or a feature, but when looking at the implementation of the .rename function for the sftp module in Paramiko this doesn't trigger MOVED_FROM and MOVED_TO, instead it triggers CREATE and DELETE events. Is this normal? What is it that paramiko does differently when renaming a file that causes these two events to be created instead of MOVED_FROM and MOVED_TO?
I have tested this with version 2.2.1 of Paramiko. This is the output of 'inotifywait -r -m /tmp/test' which illustrates the difference (the file "test" is uploaded and then renamed to "testfile"):
When using sftp from OpenSSH:
When using paramiko:
Excellent question, I don't know off the top of my head what exact protocol messages the SFTP modules use, but it would not surprise me if their initial implementation was slightly off-spec (or if the spec has changed since 2004-ish).
Don't have time to deep-dive right now but I can say that if we find you're right and Paramiko's not doing quite the right thing, I'd be open to changing it (probably in a backwards incompat release in case anyone's relying on quirks of the current approach.)
Thanks for the report!
Sounds like someone already ran into the "oops changing this wouldn't be backwards compat", I guess. Does that basically solve your problem for now? If so I might just mutate this into "replace