fix: dataset image will expired (#5021)

This commit is contained in:
Archer
2025-06-12 23:21:02 +08:00
committed by GitHub
parent f32e0ff8a8
commit 30ca3e3d5c
6 changed files with 22 additions and 25 deletions

View File

@@ -41,7 +41,6 @@ import { clearCollectionImages, removeDatasetImageExpiredTime } from '../image/u
export const createCollectionAndInsertData = async ({
dataset,
rawText,
relatedId,
imageIds,
createCollectionParams,
backupParse = false,
@@ -50,7 +49,6 @@ export const createCollectionAndInsertData = async ({
}: {
dataset: DatasetSchemaType;
rawText?: string;
relatedId?: string;
imageIds?: string[];
createCollectionParams: CreateOneCollectionParams;
@@ -258,23 +256,6 @@ export const createCollectionAndInsertData = async ({
collectionId,
session
});
if (relatedId) {
await MongoImage.updateMany(
{
teamId,
'metadata.relatedId': relatedId
},
{
// Remove expiredTime to avoid ttl expiration
$unset: {
expiredTime: 1
}
},
{
session
}
);
}
return {
collectionId: String(collectionId),

View File

@@ -46,7 +46,6 @@ async function handler(
const { collectionId, insertResults } = await createCollectionAndInsertData({
dataset,
relatedId: apiFileId,
createCollectionParams: {
...body,
teamId,

View File

@@ -31,9 +31,7 @@ async function handler(req: NextApiRequest): CreateCollectionResponse {
webPageSelector: body?.metadata?.webPageSelector
},
rawLink: link
},
relatedId: link
}
});
return {

View File

@@ -62,7 +62,6 @@ async function handler(req: NextApiRequest, res: NextApiResponse<any>): CreateCo
// 3. Create collection
const { collectionId, insertResults } = await createCollectionAndInsertData({
dataset,
relatedId: relatedImgId,
createCollectionParams: {
...collectionData,
name: collectionName,

View File

@@ -44,7 +44,6 @@ async function handler(
const { collectionId } = await createCollectionAndInsertData({
dataset: collection.dataset,
relatedId: collection.metadata?.relatedImgId,
createCollectionParams: {
...collection,
...data,

View File

@@ -30,6 +30,7 @@ import { MongoDatasetCollection } from '@fastgpt/service/core/dataset/collection
import { hashStr } from '@fastgpt/global/common/string/tools';
import { POST } from '@fastgpt/service/common/api/plusRequest';
import { pushLLMTrainingUsage } from '@fastgpt/service/support/wallet/usage/controller';
import { MongoImage } from '@fastgpt/service/common/file/image/schema';
const requestLLMPargraph = async ({
rawText,
@@ -321,6 +322,26 @@ export const datasetParseQueue = async (): Promise<any> => {
session
}
);
// 8. Remove image ttl
const relatedImgId = collection.metadata?.relatedImgId;
if (relatedImgId) {
await MongoImage.updateMany(
{
teamId: collection.teamId,
'metadata.relatedId': relatedImgId
},
{
// Remove expiredTime to avoid ttl expiration
$unset: {
expiredTime: 1
}
},
{
session
}
);
}
});
addLog.debug(`[Parse Queue] Finish`, {