deno-library / compress

compress and uncompress for Deno
MIT License
41 stars 6 forks source link

TypeError: Deno.write is not a function #18

Open richcorbs opened 1 month ago

richcorbs commented 1 month ago

I'm using Deno 2 and trying to use compress to tar and gzip a directory on one system and then ungzip and untar the directory on another. The directory contains text and binary files.

Previously I have tried 0.4.4, and 0.4.5 and I was getting Deno.read is not a function. Updating to 0.4.6 resolved this error. Yay! Now I'm getting the Deno.write error.\

The tar file is written as expected and where expected but this Deno.write error shows up during the gzip portion. A 0-byte ".gz" file is created.

This library seems to do exactly what I need if I could get it to work.

I'll look around the code a bit to see if there is anything obvious but I'm not confident in my own skills.

Any thoughts you have are appreciated if you're reading this. :-)

$ deno run --allow-read --allow-write --allow-net --allow-run main.ts --deploy --production

<a list of my files to be included in the tar.gz file>
.....

error: Uncaught (in promise) TypeError: Deno.write is not a function
    await Deno.write(this.writer.rid, headers);
               ^
    at Writer.setup (https://deno.land/x/compress@v0.4.6/gzip/writer_gzip.ts:41:16)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async GzipStream.compress (https://deno.land/x/compress@v0.4.6/gzip/gzip_stream.ts:21:5)
    at async deploy (file:///Users/rich/Code/sssg-deno/main.ts:285:3)
    at async main (file:///Users/rich/Code/sssg-deno/main.ts:56:5)
richcorbs commented 1 month ago

Is it as simple as updating writer_gzip.ts:41 to use Deno.writeFile?

richcorbs commented 1 month ago

I cloned the repo and updated writer_gzip.ts. This introduced new errors about something being a directory.

I (sloppily) coded around those errors and got it to run BUT my files were 0 byte files at the destination. :-(

richcorbs commented 1 month ago

Another data point: I created the gzip another way and was able to use compress's gunzipFile to unzip it and uncompress to untar it.

fuxingZhang commented 1 month ago

@richcorbs I haven't done js/ts related work for more than five years, and I don't have the ability to maintain it now.

Solution:

fuxingZhang commented 3 weeks ago

Landed on v0.4.7