浏览代码

deal with non existing cache folder

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

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

@@ -35,9 +35,11 @@ const version = await Bun.file(path.join(Global.Path.cache, "version"))
   .catch(() => "0")
 
 if (version !== CACHE_VERSION) {
-  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 })),
-  )
+  try {
+    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 })),
+    )
+  } catch (e) {}
   await Bun.file(path.join(Global.Path.cache, "version")).write(CACHE_VERSION)
 }