From cd762f04b89d68ccaf60b2f41aa3a7a866c2d155 Mon Sep 17 00:00:00 2001 From: Jon Fautley Date: Thu, 27 Jun 2019 12:16:14 +0000 Subject: [PATCH] sftp: Completely ignore all modtime checks if SetModTime=false --- backend/sftp/sftp.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go index 54e45c295..d7b921f26 100644 --- a/backend/sftp/sftp.go +++ b/backend/sftp/sftp.go @@ -1022,16 +1022,17 @@ func (o *Object) stat() error { // // it also updates the info field func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error { + if !o.fs.opt.SetModTime { + return nil + } c, err := o.fs.getSftpConnection() if err != nil { return errors.Wrap(err, "SetModTime") } - if o.fs.opt.SetModTime { - err = c.sftpClient.Chtimes(o.path(), modTime, modTime) - o.fs.putSftpConnection(&c, err) - if err != nil { - return errors.Wrap(err, "SetModTime failed") - } + 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 {