Browse Source

解决不被同步的文件的缓存没有被卸载的问题

gitlink
Sydonian 7 months ago
parent
commit
05dd48ba39
1 changed files with 12 additions and 9 deletions
  1. +12
    -9
      client/internal/mount/vfs/cache/cache.go

+ 12
- 9
client/internal/mount/vfs/cache/cache.go View File

@@ -471,14 +471,15 @@ func (c *Cache) scanningCache() {
}

visitCnt++
if ch.Revision() > 0 {
// 1. 本地缓存被修改了,如果一段时间内没有被使用,则进行上传

// 不存放在Package里的文件,不需要上传
if len(ch.pathComps) <= 2 {
return trie.VisitContinue
}
shouldUpload := true
// 不存放在Package里的文件,不需要上传
if len(ch.pathComps) <= 2 {
shouldUpload = false
}

if ch.Revision() > 0 && shouldUpload {
// 1. 本地缓存被修改了,如果一段时间内没有被使用,则进行上传
if time.Since(ch.state.freeTime) > c.cfg.UploadPendingTime && ch.state.uploading == nil {
fullName := packageFullName{ch.pathComps[0], ch.pathComps[1]}
pkg, ok := uploadingPkgs[fullName]
@@ -507,10 +508,12 @@ func (c *Cache) scanningCache() {
}
} else {
// 3. 卸载后的缓存,如果一段时间内没有被使用,则进行删除。
// 能达到这个阶段,则肯定已经被同步到远端了

if time.Since(ch.state.unloadTime) > c.cfg.CacheExpireTime {
ch.Delete()
// 如果文件已经同步到远端,则可以直接删除本地缓存
if ch.Revision() == 0 {
ch.Delete()
}

node.RemoveSelf(true)
}
}


Loading…
Cancel
Save