@@ -10,7 +10,6 @@ import { UsageCacheManager } from '../../UsageCacheManager'
1010import { utilAddChatMessage } from '../../utils/addChatMesage'
1111import { utilGetChatMessage } from '../../utils/getChatMessage'
1212import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
13- import logger from '../../utils/logger'
1413import { updateStorageUsage } from '../../utils/quotaUsage'
1514
1615// Add chatmessages for chatflowid
@@ -129,7 +128,7 @@ const removeAllChatMessages = async (
129128 const { totalSize } = await removeFilesFromStorage ( orgId , chatflowid , chatId )
130129 await updateStorageUsage ( orgId , workspaceId , totalSize , usageCacheManager )
131130 } catch ( e ) {
132- logger . error ( `[server]: Error deleting file storage for chatflow ${ chatflowid } , chatId ${ chatId } ` )
131+ // Don't throw error if file deletion fails because file might not exist
133132 }
134133 }
135134 const dbResponse = await appServer . AppDataSource . getRepository ( ChatMessage ) . delete ( deleteOptions )
@@ -165,8 +164,12 @@ const removeChatMessagesByMessageIds = async (
165164 await appServer . AppDataSource . getRepository ( ChatMessageFeedback ) . delete ( feedbackDeleteOptions )
166165
167166 // Delete all uploads corresponding to this chatflow/chatId
168- const { totalSize } = await removeFilesFromStorage ( orgId , chatflowid , chatId )
169- await updateStorageUsage ( orgId , workspaceId , totalSize , usageCacheManager )
167+ try {
168+ const { totalSize } = await removeFilesFromStorage ( orgId , chatflowid , chatId )
169+ await updateStorageUsage ( orgId , workspaceId , totalSize , usageCacheManager )
170+ } catch ( e ) {
171+ // Don't throw error if file deletion fails because file might not exist
172+ }
170173 }
171174
172175 // Delete executions if they exist
@@ -179,7 +182,7 @@ const removeChatMessagesByMessageIds = async (
179182 } catch ( error ) {
180183 throw new InternalFlowiseError (
181184 StatusCodes . INTERNAL_SERVER_ERROR ,
182- `Error: chatMessagesService.removeAllChatMessages - ${ getErrorMessage ( error ) } `
185+ `Error: chatMessagesService.removeChatMessagesByMessageIds - ${ getErrorMessage ( error ) } `
183186 )
184187 }
185188}
0 commit comments