Răsfoiți Sursa

fix: prevent jdtls path checks from throwing (#7052)

Guofang.Tang 1 lună în urmă
părinte
comite
8265621d48
1 a modificat fișierele cu 3 adăugiri și 2 ștergeri
  1. 3 2
      packages/opencode/src/lsp/server.ts

+ 3 - 2
packages/opencode/src/lsp/server.ts

@@ -13,6 +13,7 @@ import { Archive } from "../util/archive"
 
 export namespace LSPServer {
   const log = Log.create({ service: "lsp.server" })
+  const pathExists = async (p: string) => fs.stat(p).then(() => true).catch(() => false)
 
   export interface Handle {
     process: ChildProcessWithoutNullStreams
@@ -1145,7 +1146,7 @@ export namespace LSPServer {
       }
       const distPath = path.join(Global.Path.bin, "jdtls")
       const launcherDir = path.join(distPath, "plugins")
-      const installed = await fs.exists(launcherDir)
+      const installed = await pathExists(launcherDir)
       if (!installed) {
         if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
         log.info("Downloading JDTLS LSP server.")
@@ -1163,7 +1164,7 @@ export namespace LSPServer {
         .nothrow()
         .then(({ stdout }) => stdout.toString().trim())
       const launcherJar = path.join(launcherDir, jarFileName)
-      if (!(await fs.exists(launcherJar))) {
+      if (!(await pathExists(launcherJar))) {
         log.error(`Failed to locate the JDTLS launcher module in the installed directory: ${distPath}.`)
         return
       }