fix(fs/compiler/unpack): robustify directory removal and remove noisy diagnostic logging

This commit is contained in:
2026-03-05 12:19:24 +00:00
parent 75cb613d5e
commit c269039050
5 changed files with 22 additions and 67 deletions

View File

@@ -125,7 +125,7 @@ export class FsHelpers {
* Remove a directory recursively
*/
public static async removeDirectory(dirPath: string): Promise<void> {
await fs.promises.rm(dirPath, { recursive: true });
await fs.promises.rm(dirPath, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
}
/**
@@ -139,6 +139,15 @@ export class FsHelpers {
* Remove an empty directory
*/
public static async removeEmptyDirectory(dirPath: string): Promise<void> {
await fs.promises.rmdir(dirPath);
try {
await fs.promises.rmdir(dirPath);
} catch (err: any) {
if (err.code === 'ENOTEMPTY') {
// Filesystem metadata lag — use recursive rm as fallback
await fs.promises.rm(dirPath, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
} else if (err.code !== 'ENOENT') {
throw err;
}
}
}
}