Skip to content

Commit ffbc733

Browse files
authored
smp server: remove duplicate progress log (#1466)
1 parent 2286726 commit ffbc733

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/Simplex/Messaging/Server.hs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,24 +1867,20 @@ processServerMessages StartOptions {skipWarnings} = do
18671867
importMessages :: forall s. STMStoreClass s => Bool -> s -> FilePath -> Maybe Int64 -> Bool -> IO MessageStats
18681868
importMessages tty ms f old_ skipWarnings = do
18691869
logInfo $ "restoring messages from file " <> T.pack f
1870-
(lineCount, _, (storedMsgsCount, expiredMsgsCount, overQuota)) <-
1871-
foldLogLines tty f restoreMsg (0, Nothing, (0, 0, M.empty))
1872-
putStrLn $ progress lineCount
1870+
(_, (storedMsgsCount, expiredMsgsCount, overQuota)) <-
1871+
foldLogLines tty f restoreMsg (Nothing, (0, 0, M.empty))
18731872
renameFile f $ f <> ".bak"
18741873
mapM_ setOverQuota_ overQuota
18751874
logQueueStates ms
18761875
storedQueues <- M.size <$> readTVarIO (queues $ stmQueueStore ms)
18771876
pure MessageStats {storedMsgsCount, expiredMsgsCount, storedQueues}
18781877
where
1879-
progress i = "Processed " <> show i <> " lines"
1880-
restoreMsg :: (Int, Maybe (RecipientId, StoreQueue s), (Int, Int, M.Map RecipientId (StoreQueue s))) -> Bool -> ByteString -> IO (Int, Maybe (RecipientId, StoreQueue s), (Int, Int, M.Map RecipientId (StoreQueue s)))
1881-
restoreMsg (!i, q_, counts@(!stored, !expired, !overQuota)) eof s = do
1882-
when (tty && i `mod` 1000 == 0) $ putStr (progress i <> "\r") >> hFlush stdout
1883-
case strDecode s of
1884-
Right (MLRv3 rId msg) -> runExceptT (addToMsgQueue rId msg) >>= either (exitErr . tshow) pure
1885-
Left e
1886-
| eof -> warnOrExit (parsingErr e) $> (i + 1, q_, counts)
1887-
| otherwise -> exitErr $ parsingErr e
1878+
restoreMsg :: (Maybe (RecipientId, StoreQueue s), (Int, Int, M.Map RecipientId (StoreQueue s))) -> Bool -> ByteString -> IO (Maybe (RecipientId, StoreQueue s), (Int, Int, M.Map RecipientId (StoreQueue s)))
1879+
restoreMsg (q_, counts@(!stored, !expired, !overQuota)) eof s = case strDecode s of
1880+
Right (MLRv3 rId msg) -> runExceptT (addToMsgQueue rId msg) >>= either (exitErr . tshow) pure
1881+
Left e
1882+
| eof -> warnOrExit (parsingErr e) $> (q_, counts)
1883+
| otherwise -> exitErr $ parsingErr e
18881884
where
18891885
exitErr e = do
18901886
when tty $ putStrLn ""
@@ -1902,10 +1898,10 @@ importMessages tty ms f old_ skipWarnings = do
19021898
Left AUTH -> liftIO $ do
19031899
when tty $ putStrLn ""
19041900
warnOrExit $ "queue " <> safeDecodeUtf8 (encode $ unEntityId rId) <> " does not exist"
1905-
pure (i + 1, Nothing, counts)
1901+
pure (Nothing, counts)
19061902
Left e -> throwE e
19071903
addToQueue_ q rId msg =
1908-
(i + 1,Just (rId, q),) <$> case msg of
1904+
(Just (rId, q),) <$> case msg of
19091905
Message {msgTs}
19101906
| maybe True (systemSeconds msgTs >=) old_ -> do
19111907
writeMsg ms q False msg >>= \case

0 commit comments

Comments
 (0)