Compare commits

..

2 Commits

4 changed files with 27 additions and 12 deletions

View File

@@ -1,5 +1,12 @@
# Changelog # Changelog
## 2026-03-05 - 4.1.16 - fix(mod_unpack)
handle partial readdir results from signal-interrupted getdents64 when unpacking to ensure sibling removal and nested moves complete
- Loop readdir calls for destination directory until only the source folder remains to avoid partial-listing leftovers
- Loop readdir calls for nested directory and repeatedly rename entries until the nested directory is empty
- Prevents leftover files and incomplete moves when readdir returns partial results under signals
## 2026-03-05 - 4.1.15 - fix(mod_unpack) ## 2026-03-05 - 4.1.15 - fix(mod_unpack)
flatten nested output directory without temporary rename steps to avoid race conditions flatten nested output directory without temporary rename steps to avoid race conditions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@git.zone/tsbuild", "name": "@git.zone/tsbuild",
"version": "4.1.15", "version": "4.1.16",
"private": false, "private": false,
"description": "A tool for compiling TypeScript files using the latest nightly features, offering flexible APIs and a CLI for streamlined development.", "description": "A tool for compiling TypeScript files using the latest nightly features, offering flexible APIs and a CLI for streamlined development.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",

View File

@@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@git.zone/tsbuild', name: '@git.zone/tsbuild',
version: '4.1.15', version: '4.1.16',
description: 'A tool for compiling TypeScript files using the latest nightly features, offering flexible APIs and a CLI for streamlined development.' description: 'A tool for compiling TypeScript files using the latest nightly features, offering flexible APIs and a CLI for streamlined development.'
} }

View File

@@ -108,21 +108,29 @@ export class TsUnpacker {
const nestedPath = this.getNestedPath(); const nestedPath = this.getNestedPath();
// Step 1: Remove sibling entries (everything in dest except the source folder) // Step 1: Remove sibling entries (everything in dest except the source folder)
const destEntries = await fs.promises.readdir(this.destDir); // Loop handles partial readdir results from signal-interrupted getdents64
let destEntries = await fs.promises.readdir(this.destDir);
while (destEntries.some(e => e !== this.sourceFolderName)) {
for (const entry of destEntries) { for (const entry of destEntries) {
if (entry !== this.sourceFolderName) { if (entry !== this.sourceFolderName) {
await fs.promises.rm(path.join(this.destDir, entry), { recursive: true, force: true }); await fs.promises.rm(path.join(this.destDir, entry), { recursive: true, force: true });
} }
} }
destEntries = await fs.promises.readdir(this.destDir);
}
// Step 2: Move all contents from nested dir up to dest dir // Step 2: Move all contents from nested dir up to dest dir
const nestedEntries = await fs.promises.readdir(nestedPath); // Loop handles partial readdir results from signal-interrupted getdents64
let nestedEntries = await fs.promises.readdir(nestedPath);
while (nestedEntries.length > 0) {
for (const entry of nestedEntries) { for (const entry of nestedEntries) {
await fs.promises.rename( await fs.promises.rename(
path.join(nestedPath, entry), path.join(nestedPath, entry),
path.join(this.destDir, entry), path.join(this.destDir, entry),
); );
} }
nestedEntries = await fs.promises.readdir(nestedPath);
}
// Step 3: Remove the now-empty nested directory // Step 3: Remove the now-empty nested directory
await fs.promises.rmdir(nestedPath); await fs.promises.rmdir(nestedPath);