mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 15:20:38 +08:00
vfs: don't set modification time if it was already correct
Before this change, rclone would set the modification time of an object after it had been uploaded. However with --vfs-cache-mode writes and above, the modification time of the object is already correct as the cache backing file gets set with the correct modification time before upload. Setting the modification time causes another version to be created on backends such as S3 so it should be avoided if possible. This change checks to see if the modification time needs changing and only sets it if necessary. See: https://forum.rclone.org/t/produce-2-versions-when-overwrite-an-object-in-min-io/19634
This commit is contained in:
parent
a12b2746b4
commit
c387eb8c09
|
@ -382,6 +382,13 @@ func (f *File) _applyPendingModTime() error {
|
|||
return errors.New("Cannot apply ModTime, file object is not available")
|
||||
}
|
||||
|
||||
dt := f.pendingModTime.Sub(f.o.ModTime(context.Background()))
|
||||
modifyWindow := f.o.Fs().Precision()
|
||||
if dt < modifyWindow && dt > -modifyWindow {
|
||||
fs.Debugf(f.o, "Not setting pending mod time %v as it is already set", f.pendingModTime)
|
||||
return nil
|
||||
}
|
||||
|
||||
// set the time of the object
|
||||
err := f.o.SetModTime(context.TODO(), f.pendingModTime)
|
||||
switch err {
|
||||
|
|
Loading…
Reference in New Issue
Block a user