From 9615085b1427efe616302af4e9887f7cb84a9a0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roman=20Smr=C5=BE?= <roman.smrz@seznam.cz>
Date: Tue, 26 Jul 2022 21:45:39 +0200
Subject: Storage: flush files after write

---
 src/Storage/Internal.hs | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'src/Storage')

diff --git a/src/Storage/Internal.hs b/src/Storage/Internal.hs
index 04fdf0d..3facff2 100644
--- a/src/Storage/Internal.hs
+++ b/src/Storage/Internal.hs
@@ -230,6 +230,7 @@ writeFileOnce file content = bracket
         fileExist file >>= \case
             True  -> removeLink locked
             False -> do BL.hPut h content
+                        hFlush h
                         rename locked file
     where locked = file ++ ".lock"
 
@@ -243,11 +244,13 @@ writeFileChecked file prev content = bracket
                 removeLink locked
                 return $ Left $ Just current
             (Nothing, False) -> do B.hPut h content
+                                   hFlush h
                                    rename locked file
                                    return $ Right ()
             (Just expected, True) -> do
                 current <- B.readFile file
                 if current == expected then do B.hPut h content
+                                               hFlush h
                                                rename locked file
                                                return $ return ()
                                        else do removeLink locked
-- 
cgit v1.2.3