mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 09:04:52 +01:00
smb: fix panic if stat fails
Before this fix the smb backend could panic if a stat call failed. This fix makes it return an error instead. It should have the side effect that we do one less stat call on upload too. Fixes #8106
This commit is contained in:
parent
22e13eea47
commit
0ccfbe71e4
@ -601,9 +601,10 @@ func (o *Object) SetModTime(ctx context.Context, t time.Time) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fi, err := cn.smbShare.Stat(reqDir)
|
fi, err := cn.smbShare.Stat(reqDir)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
o.statResult = fi
|
return fmt.Errorf("SetModTime: stat: %w", err)
|
||||||
}
|
}
|
||||||
|
o.statResult = fi
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -685,7 +686,6 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
o.statResult, _ = cn.smbShare.Stat(filename)
|
|
||||||
o.fs.putConnection(&cn)
|
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)
|
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))
|
err = o.SetModTime(ctx, src.ModTime(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Update SetModTime failed: %w", err)
|
return fmt.Errorf("Update SetModTime failed: %w", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user