deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

@std/tar try to "create current directoy" which must be already exists (Include solution)

Open h76oeI6pMxU9g4p8aCpc6Q opened this issue 1 year ago • 1 comments

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

h76oeI6pMxU9g4p8aCpc6Q avatar Oct 13 '24 10:10 h76oeI6pMxU9g4p8aCpc6Q

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.

BlackAsLight avatar Oct 13 '24 10:10 BlackAsLight