diff --git a/client/internal/mount/vfs/cache/cache.go b/client/internal/mount/vfs/cache/cache.go index aac1b53..bf5a5bb 100644 --- a/client/internal/mount/vfs/cache/cache.go +++ b/client/internal/mount/vfs/cache/cache.go @@ -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) } }