1
mirror of https://github.com/rclone/rclone synced 2024-11-14 13:36:24 +01:00
rclone/vfs/vstate_string.go
Nick Craig-Wood f980f230c5 vfs: fix virtual entries causing deleted files to still appear
Before this change, if a file was created on a remote but deleted
externally from that remote then there was potential for the delete to
never be noticed.

The sequence of events was:

- Create file on VFS - creates virtual directory entry
- File deleted externally to remote before the directory refreshed
- Now the file has a virtual add but is not in the listings so will never disappear

This patch fixes it by removing all virtual directory entries except
the following when the directory is re-read.

- On remotes which can't have empty directories: virtual directory
  adds are not flushed. These will remain virtual as long as the
  directory is empty.

- For virtual file add: files that are in the process of being
  uploaded are not flushed

This patch also adds the distinction between virtually added files and
directories.

It also refactors the virtual directory logic to make it easier to follow.

Fixes #4446
2020-11-10 16:47:25 +00:00

27 lines
632 B
Go

// Code generated by "stringer -type=vState"; DO NOT EDIT.
package vfs
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[vOK-0]
_ = x[vAddFile-1]
_ = x[vAddDir-2]
_ = x[vDel-3]
}
const _vState_name = "vOKvAddFilevAddDirvDel"
var _vState_index = [...]uint8{0, 3, 11, 18, 22}
func (i vState) String() string {
if i >= vState(len(_vState_index)-1) {
return "vState(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _vState_name[_vState_index[i]:_vState_index[i+1]]
}