Xóa scene con mà không xóa scene cha

This commit is contained in:
2026-06-09 21:26:47 +07:00
parent d39d3b3d53
commit 67825b04cc
22 changed files with 1185 additions and 1486 deletions
+3 -3
View File
@@ -64,12 +64,12 @@ const cleanup = async () => {
// 6. Xóa tệp tin vật lý và bản ghi Asset
let filesDeleted = 0;
for (const asset of orphanedAssets) {
if (asset.filePath && fs.existsSync(asset.filePath)) {
if (asset.filePath) {
try {
fs.unlinkSync(asset.filePath);
await fs.promises.unlink(asset.filePath);
filesDeleted++;
} catch (e) {
console.error(` [Lỗi] Không thể xóa file: ${asset.filePath}`);
if (e.code !== 'ENOENT') console.error(` [Lỗi] Không thể xóa file: ${asset.filePath}`);
}
}
await Asset.findByIdAndDelete(asset._id);