浏览代码

fix: preserve cache dir on cleanup (#2126)

Denys Pavlov 6 月之前
父节点
当前提交
2ff4cd2c2b
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      packages/opencode/src/global/index.ts

+ 4 - 1
packages/opencode/src/global/index.ts

@@ -35,6 +35,9 @@ const version = await Bun.file(path.join(Global.Path.cache, "version"))
   .catch(() => "0")
   .catch(() => "0")
 
 
 if (version !== CACHE_VERSION) {
 if (version !== CACHE_VERSION) {
-  await fs.rm(Global.Path.cache, { recursive: true, force: true })
+  const contents = await fs.readdir(Global.Path.cache)
+  await Promise.all(
+    contents.map((item) => fs.rm(path.join(Global.Path.cache, item), { recursive: true, force: true })),
+  )
   await Bun.file(path.join(Global.Path.cache, "version")).write(CACHE_VERSION)
   await Bun.file(path.join(Global.Path.cache, "version")).write(CACHE_VERSION)
 }
 }