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

smb: fix panic if stat fails

Nick Craig-Woodc9e5f45d73ba
diff --git a/backend/smb/smb.go b/backend/smb/smb.go
index 37ac06554..ff8f40976 100644
--- a/backend/smb/smb.go
+++ b/backend/smb/smb.go
@@ -601,9 +601,10 @@ func (o *Object) SetModTime(ctx context.Context, t time.Time) (err error) {
}
fi, err := cn.smbShare.Stat(reqDir)
- if err == nil {
- o.statResult = fi
+ if err != nil {
+ return fmt.Errorf("SetModTime: stat: %w", err)
}
+ o.statResult = fi
return err
}
@@ -685,7 +686,6 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
return err
}
defer func() {
- o.statResult, _ = cn.smbShare.Stat(filename)
o.fs.putConnection(&cn)
}()
@@ -723,7 +723,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
return fmt.Errorf("Update Close failed: %w", err)
}
- // Set the modified time
+ // Set the modified time and also o.statResult
err = o.SetModTime(ctx, src.ModTime(ctx))
if err != nil {
return fmt.Errorf("Update SetModTime failed: %w", err)