mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
vfs: Add recovered items on cache reload to directory listings
Before this change, if we restarted an upload after a restart then the file would get uploaded but never added to the directory listings. This change makes sure we add virtual items to the directory cache when reloading the cache so that they show up properly.
This commit is contained in:
12
vfs/vfs.go
12
vfs/vfs.go
@@ -259,7 +259,7 @@ func (vfs *VFS) SetCacheMode(cacheMode vfscommon.CacheMode) {
|
||||
vfs.cache = nil
|
||||
if cacheMode > vfscommon.CacheModeOff {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cache, err := vfscache.New(ctx, vfs.f, &vfs.Opt) // FIXME pass on context or get from Opt?
|
||||
cache, err := vfscache.New(ctx, vfs.f, &vfs.Opt, vfs.AddVirtual) // FIXME pass on context or get from Opt?
|
||||
if err != nil {
|
||||
fs.Errorf(nil, "Failed to create vfs cache - disabling: %v", err)
|
||||
vfs.Opt.CacheMode = vfscommon.CacheModeOff
|
||||
@@ -652,3 +652,13 @@ func (vfs *VFS) ReadFile(filename string) (b []byte, err error) {
|
||||
defer fs.CheckClose(f, &err)
|
||||
return ioutil.ReadAll(f)
|
||||
}
|
||||
|
||||
// AddVirtual adds the object (file or dir) to the directory cache
|
||||
func (vfs *VFS) AddVirtual(remote string, size int64, isDir bool) error {
|
||||
dir, leaf, err := vfs.StatParent(remote)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dir.AddVirtual(leaf, size, false)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user