summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-01-28 12:35:51 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-01-28 12:35:51 -0400
commit04fe906ac6e611fd59ef44244a01e8fe61abec6f (patch)
treecfcc6f6ca79bc55606135088d609237a8aacd1b2 /Command
parent4f9336bb60ca4dc08ca271605de71415c98ec3ff (diff)
use safewritefile
Diffstat (limited to 'Command')
-rw-r--r--Command/Init.hs5
-rw-r--r--Command/Uninit.hs2
-rw-r--r--Command/Unused.hs3
3 files changed, 6 insertions, 4 deletions
diff --git a/Command/Init.hs b/Command/Init.hs
index e780c8863..2976b988d 100644
--- a/Command/Init.hs
+++ b/Command/Init.hs
@@ -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
diff --git a/Command/Uninit.hs b/Command/Uninit.hs
index 93465df37..e9406ce3a 100644
--- a/Command/Uninit.hs
+++ b/Command/Uninit.hs
@@ -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
diff --git a/Command/Unused.hs b/Command/Unused.hs
index 5e5698e38..b9dc62a32 100644
--- a/Command/Unused.hs
+++ b/Command/Unused.hs
@@ -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