Skip to content

Commit

Permalink
Fix downloading files
Browse files Browse the repository at this point in the history
  • Loading branch information
skyrising committed Jan 15, 2025
1 parent b012e09 commit ba63a64
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function downloadFile(url: string, file: string, part = false) {
const res = await fetch(url)
if (!res.ok) throw Error(`Invalid response for download: ${res.status} ${res.statusText}`)

await res.body!.pipeTo((await Deno.open(destFile, {write: true})).writable)
await res.body!.pipeTo((await Deno.open(destFile, {write: true, create: true})).writable)
if (part) {
await Deno.rename(destFile, file)
}
Expand All @@ -41,4 +41,4 @@ export async function downloadFile(url: string, file: string, part = false) {
console.error(e)
if (await exists(file)) await Deno.remove(destFile)
}
}
}

0 comments on commit ba63a64

Please sign in to comment.