mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 11:01:18 +03:00
Bugfix/Avoid throwing error when removing all chat messages if files do not exist (#5001)
avoid throwing error when removing all chat messages if files do not exist
This commit is contained in:
@@ -10,7 +10,6 @@ import { UsageCacheManager } from '../../UsageCacheManager'
|
|||||||
import { utilAddChatMessage } from '../../utils/addChatMesage'
|
import { utilAddChatMessage } from '../../utils/addChatMesage'
|
||||||
import { utilGetChatMessage } from '../../utils/getChatMessage'
|
import { utilGetChatMessage } from '../../utils/getChatMessage'
|
||||||
import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
|
import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
|
||||||
import logger from '../../utils/logger'
|
|
||||||
import { updateStorageUsage } from '../../utils/quotaUsage'
|
import { updateStorageUsage } from '../../utils/quotaUsage'
|
||||||
|
|
||||||
// Add chatmessages for chatflowid
|
// Add chatmessages for chatflowid
|
||||||
@@ -129,7 +128,7 @@ const removeAllChatMessages = async (
|
|||||||
const { totalSize } = await removeFilesFromStorage(orgId, chatflowid, chatId)
|
const { totalSize } = await removeFilesFromStorage(orgId, chatflowid, chatId)
|
||||||
await updateStorageUsage(orgId, workspaceId, totalSize, usageCacheManager)
|
await updateStorageUsage(orgId, workspaceId, totalSize, usageCacheManager)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`[server]: Error deleting file storage for chatflow ${chatflowid}, chatId ${chatId}`)
|
// Don't throw error if file deletion fails because file might not exist
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const dbResponse = await appServer.AppDataSource.getRepository(ChatMessage).delete(deleteOptions)
|
const dbResponse = await appServer.AppDataSource.getRepository(ChatMessage).delete(deleteOptions)
|
||||||
@@ -165,8 +164,12 @@ const removeChatMessagesByMessageIds = async (
|
|||||||
await appServer.AppDataSource.getRepository(ChatMessageFeedback).delete(feedbackDeleteOptions)
|
await appServer.AppDataSource.getRepository(ChatMessageFeedback).delete(feedbackDeleteOptions)
|
||||||
|
|
||||||
// Delete all uploads corresponding to this chatflow/chatId
|
// Delete all uploads corresponding to this chatflow/chatId
|
||||||
|
try {
|
||||||
const { totalSize } = await removeFilesFromStorage(orgId, chatflowid, chatId)
|
const { totalSize } = await removeFilesFromStorage(orgId, chatflowid, chatId)
|
||||||
await updateStorageUsage(orgId, workspaceId, totalSize, usageCacheManager)
|
await updateStorageUsage(orgId, workspaceId, totalSize, usageCacheManager)
|
||||||
|
} catch (e) {
|
||||||
|
// Don't throw error if file deletion fails because file might not exist
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete executions if they exist
|
// Delete executions if they exist
|
||||||
@@ -179,7 +182,7 @@ const removeChatMessagesByMessageIds = async (
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new InternalFlowiseError(
|
throw new InternalFlowiseError(
|
||||||
StatusCodes.INTERNAL_SERVER_ERROR,
|
StatusCodes.INTERNAL_SERVER_ERROR,
|
||||||
`Error: chatMessagesService.removeAllChatMessages - ${getErrorMessage(error)}`
|
`Error: chatMessagesService.removeChatMessagesByMessageIds - ${getErrorMessage(error)}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user