This commit is contained in:
2026-08-14 16:03:47 +01:00
parent fd53e3f4fb
commit dfdc3b2840
2463 changed files with 186456 additions and 111315 deletions
+6 -11
View File
@@ -5,7 +5,7 @@ import path from 'node:path';
import { Header } from './header.js';
import { list } from './list.js';
import { makeCommand } from './make-command.js';
import { isFile, } from './options.js';
import { isFile } from './options.js';
import { Pack, PackSync } from './pack.js';
// starting at the head of the file, read a Header
// If the checksum is invalid, that's our position to start writing
@@ -34,9 +34,7 @@ const replaceSync = (opt, files) => {
POSITION: for (position = 0; position < st.size; position += 512) {
for (let bufPos = 0, bytes = 0; bufPos < 512; bufPos += bytes) {
bytes = fs.readSync(fd, headBuf, bufPos, headBuf.length - bufPos, position + bufPos);
if (position === 0 &&
headBuf[0] === 0x1f &&
headBuf[1] === 0x8b) {
if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) {
throw new Error('cannot append to compressed archives');
}
if (!bytes) {
@@ -66,7 +64,7 @@ const replaceSync = (opt, files) => {
try {
fs.closeSync(fd);
}
catch (er) { }
catch { }
}
}
};
@@ -97,16 +95,14 @@ const replaceAsync = (opt, files) => {
let bufPos = 0;
const headBuf = Buffer.alloc(512);
const onread = (er, bytes) => {
if (er || typeof bytes === 'undefined') {
if (er || bytes === undefined) {
return cb(er);
}
bufPos += bytes;
if (bufPos < 512 && bytes) {
return fs.read(fd, headBuf, bufPos, headBuf.length - bufPos, position + bufPos, onread);
}
if (position === 0 &&
headBuf[0] === 0x1f &&
headBuf[1] === 0x8b) {
if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) {
return cb(new Error('cannot append to compressed archives'));
}
// truncated header
@@ -185,8 +181,7 @@ const addFilesSync = (p, files) => {
p.end();
};
const addFilesAsync = async (p, files) => {
for (let i = 0; i < files.length; i++) {
const file = String(files[i]);
for (const file of files) {
if (file.charAt(0) === '@') {
await list({
file: path.resolve(String(p.cwd), file.slice(1)),