sftp: Completely ignore all modtime checks if SetModTime=false

This commit is contained in:
Jon Fautley 2019-06-27 12:16:14 +00:00 committed by Nick Craig-Wood
parent 6907242cae
commit cd762f04b8

View file

@ -1022,16 +1022,17 @@ func (o *Object) stat() error {
// //
// it also updates the info field // it also updates the info field
func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error { func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error {
if !o.fs.opt.SetModTime {
return nil
}
c, err := o.fs.getSftpConnection() c, err := o.fs.getSftpConnection()
if err != nil { if err != nil {
return errors.Wrap(err, "SetModTime") return errors.Wrap(err, "SetModTime")
} }
if o.fs.opt.SetModTime { err = c.sftpClient.Chtimes(o.path(), modTime, modTime)
err = c.sftpClient.Chtimes(o.path(), modTime, modTime) o.fs.putSftpConnection(&c, err)
o.fs.putSftpConnection(&c, err) if err != nil {
if err != nil { return errors.Wrap(err, "SetModTime failed")
return errors.Wrap(err, "SetModTime failed")
}
} }
err = o.stat() err = o.stat()
if err != nil { if err != nil {