summaryrefslogtreecommitdiff
path: root/src/Erebos/Storage
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-07-18 21:05:19 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2024-07-18 21:05:19 +0200
commitaa48a173cb2619dc59efbfd8f8bbc036fddfd675 (patch)
treeab4202b292acb398e4949d0e3d8e7594dda84030 /src/Erebos/Storage
parent1e05216b7c9a8ce60556bb8f5bbe016b6ef3a5d9 (diff)
Storage: close handles before renaming lock files
Diffstat (limited to 'src/Erebos/Storage')
-rw-r--r--src/Erebos/Storage/Internal.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Erebos/Storage/Internal.hs b/src/Erebos/Storage/Internal.hs
index d419a5e..8b794d8 100644
--- a/src/Erebos/Storage/Internal.hs
+++ b/src/Erebos/Storage/Internal.hs
@@ -241,7 +241,7 @@ writeFileOnce file content = bracket (openLockFile locked)
doesFileExist file >>= \case
True -> removeFile locked
False -> do BL.hPut h content
- hFlush h
+ hClose h
renameFile locked file
where locked = file ++ ".lock"
@@ -254,13 +254,13 @@ writeFileChecked file prev content = bracket (openLockFile locked)
removeFile locked
return $ Left $ Just current
(Nothing, False) -> do B.hPut h content
- hFlush h
+ hClose h
renameFile locked file
return $ Right ()
(Just expected, True) -> do
current <- B.readFile file
if current == expected then do B.hPut h content
- hFlush h
+ hClose h
renameFile locked file
return $ return ()
else do removeFile locked