fix: handle file closing gracefully

This commit is contained in:
WailGree 2025-06-10 13:31:07 +02:00
parent d5382d3e6f
commit 321b4bb9c1
2 changed files with 5 additions and 3 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View file

@ -180,6 +180,7 @@ export const upload = async (
endpoint.searchParams.append("name", name); endpoint.searchParams.append("name", name);
const fh = await open(path); const fh = await open(path);
try { try {
const stream = fh.readableWebStream();
const resp = await github.request({ const resp = await github.request({
method: "POST", method: "POST",
url: endpoint.toString(), url: endpoint.toString(),
@ -188,7 +189,7 @@ export const upload = async (
"content-type": mime, "content-type": mime,
authorization: `token ${config.github_token}`, authorization: `token ${config.github_token}`,
}, },
data: fh.readableWebStream(), data: stream,
}); });
const json = resp.data; const json = resp.data;
if (resp.status !== 201) { if (resp.status !== 201) {
@ -201,7 +202,8 @@ export const upload = async (
console.log(`✅ Uploaded ${name}`); console.log(`✅ Uploaded ${name}`);
return json; return json;
} finally { } finally {
await fh.close(); await fh.close().catch(() => {
});
} }
}; };