deno_std
deno_std copied to clipboard
@std/tar try to "create current directoy" which must be already exists (Include solution)
let { UntarStream } = await import('jsr:@std/tar/untar-stream')
let { dirname, normalize } = await import('jsr:@std/path')
let { ensureDir } = await import('jsr:@std/fs')
let url = 'https://bitcoincore.org/bin/bitcoin-core-28.0/bitcoin-28.0-x86_64-linux-gnu.tar.gz'
for await (let entry of (await fetch(url)).body?.pipeThrough(new DecompressionStream('gzip')).pipeThrough(new UntarStream())) {
let path = normalize(entry.path)
await Deno.mkdir(dirname(path)) // Bug Here
// await ensureDir(dirname(path)) // Solution Here
await entry.readable?.pipeTo((await Deno.create(path)).writable)
}
Reference: https://jsr.io/@std/tar
Environment: Ubuntu 24.10 Deno 2.0.0
https://github.com/denoland/std/pull/6113
I'm a little ahead of you. Changing it to await Deno.mkdir(dirname(path), { recursive: true }) fixes your problem.