fix(fs/compiler/unpack): robustify directory removal and remove noisy diagnostic logging
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user