SFTP-Storage: Correctly Sync mtime#22294
Conversation
2e1fff3 to
5c87213
Compare
|
Looks good - but maybe @icewind1991 or so has another look at this. |
|
Thanks for taking the time to submit a pull request 👍 I had a short look at the code and phpseclib. Here are my thoughts:
It seems that the upstream implementation does everything we need.
|
I don't think we need to handle the mtime for streams. The mtime is part of the file status, a stream just handles the content. |
5c87213 to
9340fdb
Compare
Thank you for your suggestions, I have changed my commit accordingly. |
Today, this change has resulted in a sync conflict again. public function touch($path, $mtime=null) {
try {
if (!$this->file_exists($path)) {
$this->getConnection()->put($this->absPath($path), '');
} else {
$this->getConnection()->touch($this->absPath($path), $mtime);
}
} catch (\Exception $e) {
return false;
}
return true;
} |
Signed-off-by: Marcel Sander <marcel.sander@actidoo.com>
9340fdb to
6ebb83e
Compare
|
Since not many of the devs here use sftp. I think moving this to 21 to have all the things properly reviewed and possibly backported. @kesselb any idea why your suggestions did 💥 ? |
|
@kesselb can you have another look here? |
|
@msander doing just a put might not be enough to have the exact same mtime due to network round trips. |
|
what's the current state here? |
|
As there is no feedback since a while I will close this PR. If you are still willing to get this in, please address the potential comments and rebase to latest master. Then, feel free to re-open. |
Currently uploading a file to an external SFTP storage does not keep the mtime.
Besides losing this information is bad by itself, fast repeated changing / syncing of a file on the external storage, creates conflicts randomly (maybe if a change happens during the upload?).
Using the provided change, I was not able to reproduce the issue anymore.