summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-07-26 21:45:39 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2022-07-26 21:55:45 +0200
commit9615085b1427efe616302af4e9887f7cb84a9a0c (patch)
tree7f2b1843a3e9adc381e902c8924aabf599d8dee5
parent29773f1485076a5f6257c209274769c03220d22d (diff)
Storage: flush files after write
-rw-r--r--src/Storage/Internal.hs3
1 files changed, 3 insertions, 0 deletions
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