mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
4.6.4-alpha (#582)
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { MongoDatasetData } from './schema';
|
||||
import { deletePgDataById } from './pg';
|
||||
import { MongoDatasetTraining } from '../training/schema';
|
||||
import { delFileById } from '../../../common/file/gridfs/controller';
|
||||
import { delFileByFileIdList, delFileByMetadata } from '../../../common/file/gridfs/controller';
|
||||
import { BucketNameEnum } from '@fastgpt/global/common/file/constants';
|
||||
import { MongoDatasetCollection } from '../collection/schema';
|
||||
import { delDatasetFiles } from '../file/controller';
|
||||
import { delay } from '@fastgpt/global/common/system/utils';
|
||||
import { delImgByFileIdList } from '../../../common/file/image/controller';
|
||||
|
||||
/* delete all data by datasetIds */
|
||||
export async function delDatasetRelevantData({ datasetIds }: { datasetIds: string[] }) {
|
||||
@@ -17,9 +17,11 @@ export async function delDatasetRelevantData({ datasetIds }: { datasetIds: strin
|
||||
});
|
||||
|
||||
// delete related files
|
||||
await Promise.all(datasetIds.map((id) => delDatasetFiles({ datasetId: id })));
|
||||
await Promise.all(
|
||||
datasetIds.map((id) => delFileByMetadata({ bucketName: BucketNameEnum.dataset, datasetId: id }))
|
||||
);
|
||||
|
||||
await delay(1000);
|
||||
await delay(500);
|
||||
|
||||
// delete pg data
|
||||
await deletePgDataById(`dataset_id IN ('${datasetIds.join("','")}')`);
|
||||
@@ -49,17 +51,16 @@ export async function delCollectionRelevantData({
|
||||
collectionId: { $in: collectionIds }
|
||||
});
|
||||
|
||||
// delete file
|
||||
await Promise.all(
|
||||
filterFileIds.map((fileId) => {
|
||||
return delFileById({
|
||||
bucketName: BucketNameEnum.dataset,
|
||||
fileId
|
||||
});
|
||||
// delete file and imgs
|
||||
await Promise.all([
|
||||
delImgByFileIdList(filterFileIds),
|
||||
delFileByFileIdList({
|
||||
bucketName: BucketNameEnum.dataset,
|
||||
fileIdList: filterFileIds
|
||||
})
|
||||
);
|
||||
]);
|
||||
|
||||
await delay(1000);
|
||||
await delay(500);
|
||||
|
||||
// delete pg data
|
||||
await deletePgDataById(`collection_id IN ('${collectionIds.join("','")}')`);
|
||||
|
Reference in New Issue
Block a user