Xóa scene con mà không xóa scene cha
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user