formacao
This commit is contained in:
+13
-23
@@ -22,7 +22,7 @@ import { BrotliDecompress, Unzip, ZstdDecompress } from 'minizlib';
|
||||
import { Header } from './header.js';
|
||||
import { Pax } from './pax.js';
|
||||
import { ReadEntry } from './read-entry.js';
|
||||
import { warnMethod, } from './warn-method.js';
|
||||
import { warnMethod } from './warn-method.js';
|
||||
const maxMetaEntrySize = 1024 * 1024;
|
||||
const gzipHeader = Buffer.from([0x1f, 0x8b]);
|
||||
const zstdHeader = Buffer.from([0x28, 0xb5, 0x2f, 0xfd]);
|
||||
@@ -89,8 +89,7 @@ export class Parser extends EE {
|
||||
this.file = opt.file || '';
|
||||
// these BADARCHIVE errors can't be detected early. listen on DONE.
|
||||
this.on(DONE, () => {
|
||||
if (this[STATE] === 'begin' ||
|
||||
this[SAW_VALID_ENTRY] === false) {
|
||||
if (this[STATE] === 'begin' || this[SAW_VALID_ENTRY] === false) {
|
||||
// either less than 1 block of data, or all entries were invalid.
|
||||
// Either way, probably not even a tarball.
|
||||
this.warn('TAR_BAD_ARCHIVE', 'Unrecognized archive format');
|
||||
@@ -220,8 +219,7 @@ export class Parser extends EE {
|
||||
}
|
||||
else {
|
||||
this[EX] = undefined;
|
||||
entry.ignore =
|
||||
entry.ignore || !this.filter(entry.path, entry);
|
||||
entry.ignore = entry.ignore || !this.filter(entry.path, entry);
|
||||
if (entry.ignore) {
|
||||
// probably valid, just not something we care about
|
||||
this[EMIT]('ignoredEntry', entry);
|
||||
@@ -274,7 +272,7 @@ export class Parser extends EE {
|
||||
}
|
||||
[NEXTENTRY]() {
|
||||
do { } while (this[PROCESSENTRY](this[QUEUE].shift()));
|
||||
if (!this[QUEUE].length) {
|
||||
if (this[QUEUE].length === 0) {
|
||||
// At this point, there's nothing in the queue, but we may have an
|
||||
// entry which is being consumed (readEntry).
|
||||
// If we don't, then we definitely can handle more data.
|
||||
@@ -324,7 +322,7 @@ export class Parser extends EE {
|
||||
return ret;
|
||||
}
|
||||
[EMIT](ev, data, extra) {
|
||||
if (!this[QUEUE].length && !this[READENTRY]) {
|
||||
if (this[QUEUE].length === 0 && !this[READENTRY]) {
|
||||
this.emit(ev, data, extra);
|
||||
}
|
||||
else {
|
||||
@@ -471,11 +469,11 @@ export class Parser extends EE {
|
||||
}
|
||||
this[WRITING] = false;
|
||||
// return false if there's a queue, or if the current entry isn't flowing
|
||||
const ret = this[QUEUE].length ? false
|
||||
const ret = this[QUEUE].length > 0 ? false
|
||||
: this[READENTRY] ? this[READENTRY].flowing
|
||||
: true;
|
||||
// if we have no queue, then that means a clogged READENTRY
|
||||
if (!ret && !this[QUEUE].length) {
|
||||
if (!ret && this[QUEUE].length === 0) {
|
||||
this[READENTRY]?.once('drain', () => this.emit('drain'));
|
||||
}
|
||||
/* c8 ignore next */
|
||||
@@ -484,8 +482,7 @@ export class Parser extends EE {
|
||||
}
|
||||
[BUFFERCONCAT](c) {
|
||||
if (c && !this[ABORTED]) {
|
||||
this[BUFFER] =
|
||||
this[BUFFER] ? Buffer.concat([this[BUFFER], c]) : c;
|
||||
this[BUFFER] = this[BUFFER] ? Buffer.concat([this[BUFFER], c]) : c;
|
||||
}
|
||||
}
|
||||
[MAYBEEND]() {
|
||||
@@ -544,9 +541,7 @@ export class Parser extends EE {
|
||||
// the buffer. Advance the position and put any remainder in the buffer.
|
||||
let position = 0;
|
||||
const length = chunk.length;
|
||||
while (position + 512 <= length &&
|
||||
!this[ABORTED] &&
|
||||
!this[SAW_EOF]) {
|
||||
while (position + 512 <= length && !this[ABORTED] && !this[SAW_EOF]) {
|
||||
switch (this[STATE]) {
|
||||
case 'begin':
|
||||
case 'header':
|
||||
@@ -567,15 +562,10 @@ export class Parser extends EE {
|
||||
}
|
||||
}
|
||||
if (position < length) {
|
||||
if (this[BUFFER]) {
|
||||
this[BUFFER] = Buffer.concat([
|
||||
chunk.subarray(position),
|
||||
this[BUFFER],
|
||||
]);
|
||||
}
|
||||
else {
|
||||
this[BUFFER] = chunk.subarray(position);
|
||||
}
|
||||
this[BUFFER] =
|
||||
this[BUFFER] ?
|
||||
Buffer.concat([chunk.subarray(position), this[BUFFER]])
|
||||
: chunk.subarray(position);
|
||||
}
|
||||
}
|
||||
end(chunk, encoding, cb) {
|
||||
|
||||
Reference in New Issue
Block a user