Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/tar/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
}

_addFileOrDirEntry(entry, opts) {
fs.stat(entry, (err, stat) => {

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 26)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 26)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 26)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 26)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 26)

Use 'fs.promises.stat()' instead

Check warning on line 48 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 26)

Use 'fs.promises.stat()' instead
if (err) return this.emit('error', err);
if (stat.isDirectory()) return this._addDirEntry(entry, opts);
if (stat.isFile()) return this._addFileEntry(entry, opts);
Expand All @@ -58,7 +58,7 @@

_addFileEntry(entry, opts) {
// stat file to get file size
fs.stat(entry, (err, stat) => {

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 26)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 26)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 26)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 26)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 26)

Use 'fs.promises.stat()' instead

Check warning on line 61 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 26)

Use 'fs.promises.stat()' instead
if (err) return this.emit('error', err);
const entryStream = this._pack.entry({ name: opts.relativePath || path.basename(entry), size: stat.size, mode: stat.mode & 0o777 }, this._onEntryFinish.bind(this));
const stream = fs.createReadStream(entry, opts.fs);
Expand All @@ -68,7 +68,7 @@
}

_addDirEntry(entry, opts) {
fs.readdir(entry, (err, files) => {

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 26)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 26)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 26)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 26)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 26)

Use 'fs.promises.readdir()' instead

Check warning on line 71 in lib/tar/stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 26)

Use 'fs.promises.readdir()' instead
if (err) return this.emit('error', err);

const relativePath = opts.relativePath || '';
Expand Down Expand Up @@ -127,9 +127,15 @@
const waitingEntry = this._waitingEntries.shift();
if (waitingEntry) {
this.addEntry.apply(this, waitingEntry);
} else {
this._finalize();
return;
}
// A caller adding entries back to back queues the later ones only after this
// returns, and for zip the finish callback runs synchronously, so finalizing
// here would close the archive after the first entry. Give the caller a tick.
setImmediate(() => {
if (this._processing || this._waitingEntries.length > 0) return;
this._finalize();
});
}

_finalize() {
Expand Down
8 changes: 6 additions & 2 deletions lib/zip/uncompress_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// https://github.com/thejoshwolfe/yauzl#no-streaming-unzip-api

const debug = require('util').debuglog('compressing/zip/uncompress_stream');
const yauzl = require('@eggjs/yauzl');
const yauzl = require('yauzl');
const stream = require('stream');
const UncompressBaseStream = require('../base_write_stream');
const utils = require('../utils');
Expand Down Expand Up @@ -125,7 +125,11 @@ class ZipUncompressStream extends UncompressBaseStream {
const placeholder = new stream.Readable({ read() {} });
debug('directory, header: %j', header);
this.emit('entry', header, placeholder, next);
setImmediate(() => placeholder.emit('end'));
// Push EOF rather than emitting 'end' on a timer: a fabricated event fires
// whether or not the consumer has finished with the entry, so a listener
// that creates the directory asynchronously would see the next entry, a
// file inside that directory, arrive before the directory exists.
placeholder.push(null);
}
})
.on('end', () => this._finalCallback())
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
},
"homepage": "https://github.com/node-modules/compressing#readme",
"dependencies": {
"@eggjs/yauzl": "^2.11.0",
"flushwritable": "^1.0.0",
"get-ready": "^1.0.0",
"iconv-lite": "^0.7.0",
"streamifier": "^0.1.1",
"tar-stream": "^1.5.2",
"yazl": "^2.4.2"
"yauzl": "^3.4.0",
"yazl": "^3.3.1"
},
"devDependencies": {
"@types/mocha": "10",
Expand Down
2 changes: 1 addition & 1 deletion test/zip/uncompress_stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('test/zip/uncompress_stream.test.js', () => {
const uncompressStream = new compressing.zip.UncompressStream();
await assert.rejects(async () => {
await pipelinePromise(fs.createReadStream(sourceFile), uncompressStream);
}, /end of central directory record signature not found/);
}, /end of central directory record signature not found/i);
});

it('should uncompress according to file path', done => {
Expand Down
Loading