sftp: respect --no-check-dest parameter

SFTP backend attempts to get object stats after upload. This will fail in case when uploading to folder that has only write permissions (no read, list, etc.)
Change makes Update method to return "best guess" stats when --no-check-dest flag is used.
This commit is contained in:
sam-mt 2025-03-19 16:35:47 +02:00 committed by GitHub
parent 4d38424e6c
commit d270bef4e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2214,6 +2214,15 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
// Stat the file after the upload to read its stats back if o.fs.opt.SetModTime == false
if !o.fs.opt.SetModTime {
ci := fs.GetConfig(ctx)
if ci.NoCheckDest {
fs.Debugf(o, "--no-check-dest is set, so returning best guess")
o.modTime = uint32(src.ModTime(ctx).Unix())
o.size = src.Size()
o.mode = os.FileMode(0666) // regular file
return nil
}
err = o.stat(ctx)
if err == fs.ErrorObjectNotFound {
// In the specific case of o.fs.opt.SetModTime == false