fix(server): deleting stacked assets (#25874)

* fix(server): deleting stacked assets

* fix: log a warning when removing an empty directory fails
This commit is contained in:
Jason Rasmussen
2026-02-04 12:33:37 -05:00
committed by GitHub
parent 9dddccd831
commit 6cdebdd3b3
6 changed files with 127 additions and 80 deletions

View File

@@ -152,7 +152,7 @@ export class StorageRepository {
}
async unlinkDir(folder: string, options: { recursive?: boolean; force?: boolean }) {
await fs.rm(folder, options);
await fs.rm(folder, { ...options, maxRetries: 5, retryDelay: 100 });
}
async removeEmptyDirs(directory: string, self: boolean = false) {
@@ -168,7 +168,13 @@ export class StorageRepository {
if (self) {
const updated = await fs.readdir(directory);
if (updated.length === 0) {
await fs.rmdir(directory);
try {
await fs.rmdir(directory);
} catch (error: Error | any) {
if (error.code !== 'ENOTEMPTY') {
this.logger.warn(`Attempted to remove directory, but failed: ${error}`);
}
}
}
}
}