1
mirror of https://github.com/rclone/rclone synced 2024-12-21 11:45:56 +01:00

sftp: add 'set_modtime' hidden configuration option

This commit is contained in:
Jon Fautley 2018-01-04 14:52:47 +00:00 committed by Nick Craig-Wood
parent 5e83dce1f6
commit 57f1bb7bb2
2 changed files with 12 additions and 5 deletions

View File

@ -147,6 +147,11 @@ Modified times are stored on the server to 1 second precision.
Modified times are used in syncing and are fully supported.
Some SFTP servers disable setting/modifying the file modification time after
upload (for example, certain configurations of ProFTPd with mod_sftp). If you
are using one of these servers, you can set the option `set_modtime = false` in
your RClone backend configuration to disable this behaviour.
### Limitations ###
SFTP supports checksums if the same login has shell access and `md5sum`

View File

@ -812,14 +812,16 @@ func (o *Object) SetModTime(modTime time.Time) error {
if err != nil {
return errors.Wrap(err, "SetModTime")
}
err = c.sftpClient.Chtimes(o.path(), modTime, modTime)
o.fs.putSftpConnection(&c, err)
if err != nil {
return errors.Wrap(err, "SetModTime failed")
if fs.ConfigFileGetBool(o.fs.name, "set_modtime", true) {
err = c.sftpClient.Chtimes(o.path(), modTime, modTime)
o.fs.putSftpConnection(&c, err)
if err != nil {
return errors.Wrap(err, "SetModTime failed")
}
}
err = o.stat()
if err != nil {
return errors.Wrap(err, "SetModTime failed")
return errors.Wrap(err, "SetModTime stat failed")
}
return nil
}