core: fix sending file to empty group (#2191)
This commit is contained in:
@@ -1576,7 +1576,7 @@ processChatCommand = \case
|
|||||||
fileInline = inlineFileMode mc inlineFiles chunks n
|
fileInline = inlineFileMode mc inlineFiles chunks n
|
||||||
fileMode = case xftpCfg of
|
fileMode = case xftpCfg of
|
||||||
Just cfg
|
Just cfg
|
||||||
| fileInline == Just IFMSent || fileSize < minFileSize cfg -> SendFileSMP fileInline
|
| fileInline == Just IFMSent || fileSize < minFileSize cfg || n <= 0 -> SendFileSMP fileInline
|
||||||
| otherwise -> SendFileXFTP
|
| otherwise -> SendFileXFTP
|
||||||
_ -> SendFileSMP fileInline
|
_ -> SendFileSMP fileInline
|
||||||
pure (fileSize, fileMode)
|
pure (fileSize, fileMode)
|
||||||
@@ -1778,7 +1778,9 @@ assertDirectAllowed user dir ct event =
|
|||||||
_ -> True
|
_ -> True
|
||||||
|
|
||||||
roundedFDCount :: Int -> Int
|
roundedFDCount :: Int -> Int
|
||||||
roundedFDCount n = max 4 $ fromIntegral $ (2 :: Integer) ^ (ceiling (logBase 2 (fromIntegral n) :: Double) :: Integer)
|
roundedFDCount n
|
||||||
|
| n <= 0 = 4
|
||||||
|
| otherwise = max 4 $ fromIntegral $ (2 :: Integer) ^ (ceiling (logBase 2 (fromIntegral n) :: Double) :: Integer)
|
||||||
|
|
||||||
startExpireCIThread :: forall m. ChatMonad' m => User -> m ()
|
startExpireCIThread :: forall m. ChatMonad' m => User -> m ()
|
||||||
startExpireCIThread user@User {userId} = do
|
startExpireCIThread user@User {userId} = do
|
||||||
|
|||||||
@@ -964,6 +964,9 @@ testAsyncGroupFileTransfer tmp = do
|
|||||||
|
|
||||||
testXFTPRoundFDCount :: Expectation
|
testXFTPRoundFDCount :: Expectation
|
||||||
testXFTPRoundFDCount = do
|
testXFTPRoundFDCount = do
|
||||||
|
roundedFDCount (-100) `shouldBe` 4
|
||||||
|
roundedFDCount (-1) `shouldBe` 4
|
||||||
|
roundedFDCount 0 `shouldBe` 4
|
||||||
roundedFDCount 1 `shouldBe` 4
|
roundedFDCount 1 `shouldBe` 4
|
||||||
roundedFDCount 2 `shouldBe` 4
|
roundedFDCount 2 `shouldBe` 4
|
||||||
roundedFDCount 4 `shouldBe` 4
|
roundedFDCount 4 `shouldBe` 4
|
||||||
|
|||||||
Reference in New Issue
Block a user