use safewritefile

This commit is contained in:
Joey Hess 2011-01-28 12:35:51 -04:00
parent 4f9336bb60
commit 04fe906ac6
4 changed files with 7 additions and 11 deletions

View file

@ -20,6 +20,7 @@ import Version
import Messages
import Locations
import Types
import Utility
command :: [Command]
command = [Command "init" paramDesc seek
@ -61,7 +62,7 @@ gitAttributesWrite repo = do
exists <- doesFileExist attributes
if not exists
then do
writeFile attributes $ attrLine ++ "\n"
safeWriteFile attributes $ attrLine ++ "\n"
commit
else do
content <- readFile attributes
@ -85,7 +86,7 @@ gitPreCommitHookWrite repo = do
if exists
then warning $ "pre-commit hook (" ++ hook ++ ") already exists, not configuring"
else liftIO $ do
writeFile hook preCommitScript
safeWriteFile hook preCommitScript
p <- getPermissions hook
setPermissions hook $ p {executable = True}
where

View file

@ -59,5 +59,5 @@ gitAttributesUnWrite repo = do
attrexists <- doesFileExist attributes
when attrexists $ do
c <- readFileStrict attributes
writeFile attributes $ unlines $
safeWriteFile attributes $ unlines $
filter (/= Command.Init.attrLine) $ lines c

View file

@ -16,6 +16,7 @@ import Types
import Content
import Messages
import Locations
import Utility
import qualified Annex
import qualified GitRepo as Git
import qualified Backend
@ -43,7 +44,7 @@ checkUnused = do
unused <- unusedKeys
let list = number 1 unused
g <- Annex.gitRepo
liftIO $ writeFile (gitAnnexUnusedLog g) $ unlines $
liftIO $ safeWriteFile (gitAnnexUnusedLog g) $ unlines $
map (\(n, k) -> show n ++ " " ++ show k) list
if null unused
then return True