Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 89a4f1c

Browse files
committed
tweak: add .catch for extractZip calls
1 parent c0c61b2 commit 89a4f1c

1 file changed

Lines changed: 42 additions & 6 deletions

File tree

packages/opencode/src/lsp/server.ts

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,13 @@ export namespace LSPServer {
177177
const zipPath = path.join(Global.Path.bin, "vscode-eslint.zip")
178178
await Bun.file(zipPath).write(response)
179179

180-
await Archive.extractZip(zipPath, Global.Path.bin)
180+
const ok = await Archive.extractZip(zipPath, Global.Path.bin)
181+
.then(() => true)
182+
.catch((error) => {
183+
log.error("Failed to extract vscode-eslint archive", { error })
184+
return false
185+
})
186+
if (!ok) return
181187
await fs.rm(zipPath, { force: true })
182188

183189
const extractedPath = path.join(Global.Path.bin, "vscode-eslint-main")
@@ -439,7 +445,13 @@ export namespace LSPServer {
439445
const zipPath = path.join(Global.Path.bin, "elixir-ls.zip")
440446
await Bun.file(zipPath).write(response)
441447

442-
await Archive.extractZip(zipPath, Global.Path.bin)
448+
const ok = await Archive.extractZip(zipPath, Global.Path.bin)
449+
.then(() => true)
450+
.catch((error) => {
451+
log.error("Failed to extract elixir-ls archive", { error })
452+
return false
453+
})
454+
if (!ok) return
443455

444456
await fs.rm(zipPath, {
445457
force: true,
@@ -542,7 +554,13 @@ export namespace LSPServer {
542554
await Bun.file(tempPath).write(downloadResponse)
543555

544556
if (ext === "zip") {
545-
await Archive.extractZip(tempPath, Global.Path.bin)
557+
const ok = await Archive.extractZip(tempPath, Global.Path.bin)
558+
.then(() => true)
559+
.catch((error) => {
560+
log.error("Failed to extract zls archive", { error })
561+
return false
562+
})
563+
if (!ok) return
546564
} else {
547565
await $`tar -xf ${tempPath}`.cwd(Global.Path.bin).nothrow()
548566
}
@@ -841,7 +859,13 @@ export namespace LSPServer {
841859
}
842860

843861
if (zip) {
844-
await Archive.extractZip(archive, Global.Path.bin)
862+
const ok = await Archive.extractZip(archive, Global.Path.bin)
863+
.then(() => true)
864+
.catch((error) => {
865+
log.error("Failed to extract clangd archive", { error })
866+
return false
867+
})
868+
if (!ok) return
845869
}
846870
if (tar) {
847871
await $`tar -xf ${archive}`.cwd(Global.Path.bin).nothrow()
@@ -1404,7 +1428,13 @@ export namespace LSPServer {
14041428
const tempPath = path.join(Global.Path.bin, assetName)
14051429
await Bun.file(tempPath).write(downloadResponse)
14061430

1407-
await Archive.extractZip(tempPath, Global.Path.bin)
1431+
const ok = await Archive.extractZip(tempPath, Global.Path.bin)
1432+
.then(() => true)
1433+
.catch((error) => {
1434+
log.error("Failed to extract terraform-ls archive", { error })
1435+
return false
1436+
})
1437+
if (!ok) return
14081438
await fs.rm(tempPath, { force: true })
14091439

14101440
bin = path.join(Global.Path.bin, "terraform-ls" + (platform === "win32" ? ".exe" : ""))
@@ -1489,7 +1519,13 @@ export namespace LSPServer {
14891519
await Bun.file(tempPath).write(downloadResponse)
14901520

14911521
if (ext === "zip") {
1492-
await Archive.extractZip(tempPath, Global.Path.bin)
1522+
const ok = await Archive.extractZip(tempPath, Global.Path.bin)
1523+
.then(() => true)
1524+
.catch((error) => {
1525+
log.error("Failed to extract texlab archive", { error })
1526+
return false
1527+
})
1528+
if (!ok) return
14931529
}
14941530
if (ext === "tar.gz") {
14951531
await $`tar -xzf ${tempPath}`.cwd(Global.Path.bin).nothrow()

0 commit comments

Comments
 (0)