vfs: fix modtime set if --vfs-cache-mode writes/full and no write
When using --vfs-cache-mode writes or full if a file was opened for write intent, the modtime was set and the file was closed without being modified the modtime would never be written back to storage. The sequence of events - app opens file with write intent - app does set modtime - rclone sets the modtime on the cache file, but not the remote file because it is open for write and can't be set yet - app closes the file without changing it - rclone doesn't upload the file because the file wasn't changed so the modtime doesn't get updated This fixes the problem by making sure any unapplied modtime changes are applied even if the file is not modified when being closed. Fixes #4795
This commit is contained in:
@@ -158,6 +158,9 @@ func (fh *RWFileHandle) close() (err error) {
|
||||
if fh.opened {
|
||||
err = fh.item.Close(fh.file.setObject)
|
||||
fh.opened = false
|
||||
} else {
|
||||
// apply any pending mod times if any
|
||||
_ = fh.file.applyPendingModTime()
|
||||
}
|
||||
|
||||
if !fh.readOnly() {
|
||||
|
||||
Reference in New Issue
Block a user