Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

sftp: fix post transfer copies failing with 0 size when using set_modtime=false

Nick Craig-Woode4f1e1912771
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go
index ec98c1719..7e5be399c 100644
--- a/backend/sftp/sftp.go
+++ b/backend/sftp/sftp.go
@@ -1102,19 +1102,18 @@ 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")
- }
- err = c.sftpClient.Chtimes(o.path(), modTime, modTime)
- o.fs.putSftpConnection(&c, err)
- if err != nil {
- return errors.Wrap(err, "SetModTime failed")
+ if o.fs.opt.SetModTime {
+ c, err := o.fs.getSftpConnection()
+ 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")
+ }
}
- err = o.stat()
+ err := o.stat()
if err != nil {
return errors.Wrap(err, "SetModTime stat failed")
}