core: temp-folder option (#3905)

This commit is contained in:
spaced4ndy
2024-03-14 10:59:20 +04:00
committed by GitHub
parent 240ca30f91
commit f3eeb9dcc2
6 changed files with 15 additions and 2 deletions

View File

@@ -80,6 +80,7 @@ mkChatOpts BroadcastBotOpts {coreOptions} =
chatCmdLog = CCLNone,
chatServerPort = Nothing,
optFilesFolder = Nothing,
optTempDirectory = Nothing,
showReactions = False,
allowInstantFiles = True,
autoAcceptFileSize = 0,

View File

@@ -80,6 +80,7 @@ mkChatOpts DirectoryOpts {coreOptions} =
chatCmdLog = CCLNone,
chatServerPort = Nothing,
optFilesFolder = Nothing,
optTempDirectory = Nothing,
showReactions = False,
allowInstantFiles = True,
autoAcceptFileSize = 0,

View File

@@ -211,7 +211,7 @@ newChatController
ChatDatabase {chatStore, agentStore}
user
cfg@ChatConfig {agentConfig = aCfg, defaultServers, inlineFiles, deviceNameForRemote}
ChatOpts {coreOptions = CoreChatOpts {smpServers, xftpServers, networkConfig, logLevel, logConnections, logServerHosts, logFile, tbqSize, highlyAvailable}, deviceName, optFilesFolder, showReactions, allowInstantFiles, autoAcceptFileSize}
ChatOpts {coreOptions = CoreChatOpts {smpServers, xftpServers, networkConfig, logLevel, logConnections, logServerHosts, logFile, tbqSize, highlyAvailable}, deviceName, optFilesFolder, optTempDirectory, showReactions, allowInstantFiles, autoAcceptFileSize}
backgroundMode = do
let inlineFiles' = if allowInstantFiles || autoAcceptFileSize > 0 then inlineFiles else inlineFiles {sendChunks = 0, receiveInstant = False}
config = cfg {logLevel, showReactions, tbqSize, subscriptionEvents = logConnections, hostEvents = logServerHosts, defaultServers = configServers, inlineFiles = inlineFiles', autoAcceptFileSize, highlyAvailable}
@@ -245,7 +245,7 @@ newChatController
chatActivated <- newTVarIO True
showLiveItems <- newTVarIO False
encryptLocalFiles <- newTVarIO False
tempDirectory <- newTVarIO Nothing
tempDirectory <- newTVarIO optTempDirectory
contactMergeEnabled <- newTVarIO True
pqExperimentalEnabled <- newTVarIO PQSupportOff
pure

View File

@@ -207,6 +207,7 @@ mobileChatOpts dbFilePrefix =
chatCmdLog = CCLNone,
chatServerPort = Nothing,
optFilesFolder = Nothing,
optTempDirectory = Nothing,
showReactions = False,
allowInstantFiles = True,
autoAcceptFileSize = 0,

View File

@@ -41,6 +41,7 @@ data ChatOpts = ChatOpts
chatCmdLog :: ChatCmdLog,
chatServerPort :: Maybe String,
optFilesFolder :: Maybe FilePath,
optTempDirectory :: Maybe FilePath,
showReactions :: Bool,
allowInstantFiles :: Bool,
autoAcceptFileSize :: Integer,
@@ -258,6 +259,13 @@ chatOptsP appDir defaultDbFileName = do
<> metavar "FOLDER"
<> help "Folder to use for sent and received files"
)
optTempDirectory <-
optional $
strOption
( long "temp-folder"
<> metavar "FOLDER"
<> help "Folder for temporary encrypted files (default: system temp directory)"
)
showReactions <-
switch
( long "reactions"
@@ -304,6 +312,7 @@ chatOptsP appDir defaultDbFileName = do
chatCmdLog,
chatServerPort,
optFilesFolder,
optTempDirectory,
showReactions,
allowInstantFiles,
autoAcceptFileSize,

View File

@@ -74,6 +74,7 @@ testOpts =
chatCmdLog = CCLNone,
chatServerPort = Nothing,
optFilesFolder = Nothing,
optTempDirectory = Nothing,
showReactions = True,
allowInstantFiles = True,
autoAcceptFileSize = 0,