From e659f4a64efdf15bf9ba19ff1fb2ab6bde946da8 Mon Sep 17 00:00:00 2001 From: shum Date: Thu, 2 Apr 2026 13:16:58 +0000 Subject: [PATCH] fix: clean up disk file when setFilePath fails in receiveServerFile When setFilePath fails (file deleted or blocked concurrently, or duplicate upload), the uploaded file was left orphaned on disk with no DB record pointing to it. Now the file is removed on failure, matching the cleanup in the receiveChunk error path. --- src/Simplex/FileTransfer/Server.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Simplex/FileTransfer/Server.hs b/src/Simplex/FileTransfer/Server.hs index 125bc4600..4faed8499 100644 --- a/src/Simplex/FileTransfer/Server.hs +++ b/src/Simplex/FileTransfer/Server.hs @@ -570,6 +570,7 @@ processXFTPRequest HTTP2Body {bodyPart} = \case Left _e -> do us <- asks usedStorage atomically $ modifyTVar' us $ subtract (fromIntegral size) + liftIO $ whenM (doesFileExist fPath) (removeFile fPath) `catch` logFileError pure $ FRErr AUTH Left e -> do us <- asks usedStorage