mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 15:20:38 +08:00
vfs: fix modtime changing when reading file into cache - fixes #5277
Before this change but after:
aea8776a43
vfs: fix modtimes not updating when writing via cache #4763
When a file was opened read-only the modtime was read from the cached
file. However this modtime wasn't correct leading to an incorrect
result.
This change fixes the definition of `item.IsDirty` to be true only
when the data is dirty. This fixes the problem as a read only file
isn't considered dirty.
This commit is contained in:
parent
b78c9a65fa
commit
00a0ee1899
|
@ -549,7 +549,7 @@ func (c *Cache) purgeClean(quota int64) {
|
|||
|
||||
// Make a slice of clean cache files
|
||||
for _, item := range c.item {
|
||||
if !item.IsDataDirty() {
|
||||
if !item.IsDirty() {
|
||||
items = append(items, item)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -450,15 +450,8 @@ func (item *Item) Dirty() {
|
|||
item.mu.Unlock()
|
||||
}
|
||||
|
||||
// IsDirty returns true if the item is dirty
|
||||
// IsDirty returns true if the item data is dirty
|
||||
func (item *Item) IsDirty() bool {
|
||||
item.mu.Lock()
|
||||
defer item.mu.Unlock()
|
||||
return item.metaDirty || item.info.Dirty
|
||||
}
|
||||
|
||||
// IsDataDirty returns true if the item's data is dirty
|
||||
func (item *Item) IsDataDirty() bool {
|
||||
item.mu.Lock()
|
||||
defer item.mu.Unlock()
|
||||
return item.info.Dirty
|
||||
|
|
Loading…
Reference in New Issue
Block a user