packages feed

cautious-file 0.1.4 → 0.1.5

raw patch · 2 files changed

+5/−3 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

cautious-file.cabal view
@@ -1,5 +1,5 @@ name:                cautious-file-version:             0.1.4+version:             0.1.5 Cabal-Version:	     >= 1.6 synopsis:            Ways to write a file cautiously, to reduce the chances of problems such as data loss due to crashes or power failures description:         If the posix flag is enabled, posix-specific functions are used to reduce the chance of data loss further
src/System/IO/Cautious.hs view
@@ -18,6 +18,9 @@ import System.FilePath (splitFileName) import System.IO (openTempFile) #ifdef _POSIX+import Control.Exception (tryJust)+import Control.Monad (guard)+import System.IO.Error (isDoesNotExistError) import System.Posix.ByteLevel (writeAllL) import System.Posix.Files (fileMode, getFileStatus, setFdMode) import System.Posix.Fsync (fsync)@@ -47,8 +50,7 @@ #ifdef _POSIX     fd <- handleToFd handle     writeAllL fd bs-    st <- getFileStatus cfp-    setFdMode fd $ fileMode st+    tryJust (\e -> guard (isDoesNotExistError e) >> return ()) $ setFdMode fd . fileMode =<< getFileStatus cfp     fsync fd     closeFd fd #else