Skip to content

Commit 8d56b0b

Browse files
authored
agent: allow starting only XFTP sending workers (#1232)
* agent: allow starting only XFTP sending workers * use Bool param * flip bool * update
1 parent b40d55c commit 8d56b0b

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Simplex/FileTransfer/Agent.hs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
module Simplex.FileTransfer.Agent
1414
( startXFTPWorkers,
15+
startXFTPSndWorkers,
1516
closeXFTPAgent,
1617
toFSFilePath,
1718
-- Receiving files
@@ -82,13 +83,21 @@ import UnliftIO.Directory
8283
import qualified UnliftIO.Exception as E
8384

8485
startXFTPWorkers :: AgentClient -> Maybe FilePath -> AM ()
85-
startXFTPWorkers c workDir = do
86+
startXFTPWorkers = startXFTPWorkers_ True
87+
{-# INLINE startXFTPWorkers #-}
88+
89+
startXFTPSndWorkers :: AgentClient -> Maybe FilePath -> AM ()
90+
startXFTPSndWorkers = startXFTPWorkers_ False
91+
{-# INLINE startXFTPSndWorkers #-}
92+
93+
startXFTPWorkers_ :: Bool -> AgentClient -> Maybe FilePath -> AM ()
94+
startXFTPWorkers_ allWorkers c workDir = do
8695
wd <- asks $ xftpWorkDir . xftpAgent
8796
atomically $ writeTVar wd workDir
8897
cfg <- asks config
89-
startRcvFiles cfg
98+
when allWorkers $ startRcvFiles cfg
9099
startSndFiles cfg
91-
startDelFiles cfg
100+
when allWorkers $ startDelFiles cfg
92101
where
93102
startRcvFiles :: AgentConfig -> AM ()
94103
startRcvFiles AgentConfig {rcvFilesTTL} = do

src/Simplex/Messaging/Agent.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ module Simplex.Messaging.Agent
9292
getNtfTokenData,
9393
toggleConnectionNtfs,
9494
xftpStartWorkers,
95+
xftpStartSndWorkers,
9596
xftpReceiveFile,
9697
xftpDeleteRcvFile,
9798
xftpDeleteRcvFiles,
@@ -146,7 +147,7 @@ import Data.Time.Clock
146147
import Data.Time.Clock.System (systemToUTCTime)
147148
import Data.Traversable (mapAccumL)
148149
import Data.Word (Word16)
149-
import Simplex.FileTransfer.Agent (closeXFTPAgent, deleteSndFileInternal, deleteSndFileRemote, deleteSndFilesInternal, deleteSndFilesRemote, startXFTPWorkers, toFSFilePath, xftpDeleteRcvFile', xftpDeleteRcvFiles', xftpReceiveFile', xftpSendDescription', xftpSendFile')
150+
import Simplex.FileTransfer.Agent (closeXFTPAgent, deleteSndFileInternal, deleteSndFileRemote, deleteSndFilesInternal, deleteSndFilesRemote, startXFTPSndWorkers, startXFTPWorkers, toFSFilePath, xftpDeleteRcvFile', xftpDeleteRcvFiles', xftpReceiveFile', xftpSendDescription', xftpSendFile')
150151
import Simplex.FileTransfer.Description (ValidFileDescription)
151152
import Simplex.FileTransfer.Protocol (FileParty (..))
152153
import Simplex.FileTransfer.Types (RcvFileId, SndFileId)
@@ -522,6 +523,10 @@ xftpStartWorkers :: AgentClient -> Maybe FilePath -> AE ()
522523
xftpStartWorkers c = withAgentEnv c . startXFTPWorkers c
523524
{-# INLINE xftpStartWorkers #-}
524525

526+
xftpStartSndWorkers :: AgentClient -> Maybe FilePath -> AE ()
527+
xftpStartSndWorkers c = withAgentEnv c . startXFTPSndWorkers c
528+
{-# INLINE xftpStartSndWorkers #-}
529+
525530
-- | Receive XFTP file
526531
xftpReceiveFile :: AgentClient -> UserId -> ValidFileDescription 'FRecipient -> Maybe CryptoFileArgs -> Bool -> AE RcvFileId
527532
xftpReceiveFile c = withAgentEnv c .:: xftpReceiveFile' c

0 commit comments

Comments
 (0)