From 05dd48ba39ae537a57b1f46f0a989dcba0a99620 Mon Sep 17 00:00:00 2001 From: Sydonian <794346190@qq.com> Date: Fri, 11 Apr 2025 10:19:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=8D=E8=A2=AB=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E7=9A=84=E6=96=87=E4=BB=B6=E7=9A=84=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=A2=AB=E5=8D=B8=E8=BD=BD=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/internal/mount/vfs/cache/cache.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) 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) } }