mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 20:25:12 -05:00
fix(std/tar): fix constant condition (#8010)
This commit is contained in:
parent
f91c1155f0
commit
d3dea24560
2 changed files with 13 additions and 6 deletions
|
@ -485,7 +485,10 @@ class TarEntry implements Reader {
|
||||||
entryBytesLeft,
|
entryBytesLeft,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (entryBytesLeft <= 0) return null;
|
if (entryBytesLeft <= 0) {
|
||||||
|
this.#consumed = true;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const block = new Uint8Array(bufSize);
|
const block = new Uint8Array(bufSize);
|
||||||
const n = await readBlock(this.#reader, block);
|
const n = await readBlock(this.#reader, block);
|
||||||
|
@ -493,9 +496,7 @@ class TarEntry implements Reader {
|
||||||
|
|
||||||
this.#read += n || 0;
|
this.#read += n || 0;
|
||||||
if (n === null || bytesLeft <= 0) {
|
if (n === null || bytesLeft <= 0) {
|
||||||
// FIXME(bartlomieju): this condition makes no sense
|
if (n === null) this.#consumed = true;
|
||||||
// deno-lint-ignore no-constant-condition
|
|
||||||
if (null) this.#consumed = true;
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,9 @@ Deno.test("appendFileWithLongNameToTarArchive", async function (): Promise<
|
||||||
const untar = new Untar(tar.getReader());
|
const untar = new Untar(tar.getReader());
|
||||||
const result = await untar.extract();
|
const result = await untar.extract();
|
||||||
assert(result !== null);
|
assert(result !== null);
|
||||||
|
assert(!result.consumed);
|
||||||
const untarText = new TextDecoder("utf-8").decode(await Deno.readAll(result));
|
const untarText = new TextDecoder("utf-8").decode(await Deno.readAll(result));
|
||||||
|
assert(result.consumed);
|
||||||
|
|
||||||
// tests
|
// tests
|
||||||
assertEquals(result.fileName, fileName);
|
assertEquals(result.fileName, fileName);
|
||||||
|
@ -137,6 +139,7 @@ Deno.test("untarAsyncIterator", async function (): Promise<void> {
|
||||||
// read data from a tar archive
|
// read data from a tar archive
|
||||||
const untar = new Untar(tar.getReader());
|
const untar = new Untar(tar.getReader());
|
||||||
|
|
||||||
|
let lastEntry;
|
||||||
for await (const entry of untar) {
|
for await (const entry of untar) {
|
||||||
const expected = entries.shift();
|
const expected = entries.shift();
|
||||||
assert(expected);
|
assert(expected);
|
||||||
|
@ -145,11 +148,14 @@ Deno.test("untarAsyncIterator", async function (): Promise<void> {
|
||||||
if (expected.filePath) {
|
if (expected.filePath) {
|
||||||
content = await Deno.readFile(expected.filePath);
|
content = await Deno.readFile(expected.filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(content, await Deno.readAll(entry));
|
assertEquals(content, await Deno.readAll(entry));
|
||||||
assertEquals(expected.name, entry.fileName);
|
assertEquals(expected.name, entry.fileName);
|
||||||
}
|
|
||||||
|
|
||||||
|
if (lastEntry) assert(lastEntry.consumed);
|
||||||
|
lastEntry = entry;
|
||||||
|
}
|
||||||
|
assert(lastEntry);
|
||||||
|
assert(lastEntry.consumed);
|
||||||
assertEquals(entries.length, 0);
|
assertEquals(entries.length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue