xftp: recreate work directory if missing before creating transfer prefix path#1823
Open
Narasimha-sc wants to merge 2 commits into
Open
xftp: recreate work directory if missing before creating transfer prefix path#1823Narasimha-sc wants to merge 2 commits into
Narasimha-sc wants to merge 2 commits into
Conversation
…fix path xftpSendFile', xftpSendDescription' and xftpReceiveFile' create their per-transfer work directory with a non-recursive createDirectory on the path returned by getPrefixPath, which assumes the configured XFTP work directory already exists. If that directory is removed while the app is running (e.g. a temp/disk cleaner, profile sync or manual deletion), every subsequent transfer fails with "CreateDirectory ...: does not exist" and cannot recover until restart. Ensure the work directory exists in getPrefixPath via createDirectoryIfMissing True, covering all three entry points (and the chunk/tmp paths built from getXFTPWorkPath).
Sends a file after removing the agent work directory (simulating a temp/disk cleaner, roaming-profile sync or manual deletion). Fails without the getPrefixPath fix with "createDirectory ...: does not exist", passes with it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
xftpSendFile',xftpSendDescription'andxftpReceiveFile'create their per-transfer work directory with a non-recursivecreateDirectoryon the path fromgetPrefixPath, which assumes the configured XFTP work directory already exists. If that directory is removed while the app is running (third-party temp/disk cleaner, roaming-profile sync, or manual deletion), every subsequent transfer fails and cannot recover until the app is restarted.Reported from simplex-chat desktop (Windows):
...\Roaming\SimpleX\tmpis the work directory; it is created once at startup but never re-created before a transfer.Root cause
src/Simplex/FileTransfer/Agent.hs:Fix
Ensure the work directory exists in
getPrefixPathwithcreateDirectoryIfMissing True. This is a single point that covers all three transfer entry points (send, send-description, receive) and the chunk/tmp paths built fromgetXFTPWorkPathviatoFSFilePath. The individualcreateDirectory prefixPathcalls are unchanged —uniqueCombinestill yields a fresh name.Testing
Added a regression test (
should recreate work directory removed while running before sending) that removes the agent work directory after workers start, then sends a file.Verified red→green locally (GHC 9.6.3), running only the new test:
1 example, 1 failure—createDirectory: does not existon…/work/<ts>_snd.xftp(reproduces the reported error).1 example, 0 failures.The full
/XFTP/XFTP agent/group also passes with the fix (27 examples, 0 failures, 1 pending), confirming no regression to normal transfers.Notes
createDirectoryIfMissingis already in scope (import UnliftIO.Directory).createDirectorycalls that build paths inside an already-createdprefixPathare intentionally left as-is; their parent exists by construction.