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:
parent
5e83dce1f6
commit
57f1bb7bb2
@ -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`
|
||||
|
12
sftp/sftp.go
12
sftp/sftp.go
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user