mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-15 23:55:36 +00:00
feat: config chat file expired time
This commit is contained in:
@@ -50,6 +50,8 @@ LOG_LEVEL=debug
|
||||
STORE_LOG_LEVEL=warn
|
||||
|
||||
# 安全配置
|
||||
# 对话文件 n 天过期
|
||||
CHAT_FILE_EXPIRE_TIME=7
|
||||
# 启动 IP 限流(true),部分接口增加了 ip 限流策略,防止非正常请求操作。
|
||||
USE_IP_LIMIT=false
|
||||
# 工作流最大运行次数,避免极端的死循环情况
|
||||
|
@@ -28,10 +28,11 @@ const setClearTmpUploadFilesCron = () => {
|
||||
};
|
||||
|
||||
const clearInvalidDataCron = () => {
|
||||
// Clear files
|
||||
setCron('0 */1 * * *', async () => {
|
||||
if (
|
||||
await checkTimerLock({
|
||||
timerId: TimerIdEnum.checkInValidDatasetFiles,
|
||||
timerId: TimerIdEnum.checkExpiredFiles,
|
||||
lockMinuted: 59
|
||||
})
|
||||
) {
|
||||
|
@@ -71,8 +71,10 @@ export async function checkInvalidDatasetFiles(start: Date, end: Date) {
|
||||
export const removeExpiredChatFiles = async () => {
|
||||
let deleteFileAmount = 0;
|
||||
const collection = getGFSCollection(BucketNameEnum.chat);
|
||||
|
||||
const expireTime = Number(process.env.CHAT_FILE_EXPIRE_TIME || 7);
|
||||
const where = {
|
||||
uploadDate: { $lte: addDays(new Date(), -7) }
|
||||
uploadDate: { $lte: addDays(new Date(), -expireTime) }
|
||||
};
|
||||
|
||||
// get all file _id
|
||||
|
Reference in New Issue
Block a user