summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-06 13:13:13 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-06 13:13:13 -0400
commit993e6459a38817a9062aafae7552a668c2db7a31 (patch)
tree900b38c923644d9f8b7eaf92ec240aa610551780 /Command
parent723eb19bbf30d502cb6979655b8013de49ce0b5e (diff)
factor out nukeFile
Diffstat (limited to 'Command')
-rw-r--r--Command/Add.hs9
-rw-r--r--Command/DropUnused.hs2
2 files changed, 4 insertions, 7 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index 7fbfa6e7f..d83817d72 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -57,13 +57,10 @@ lockDown file = do
createAnnexDirectory tmp
pid <- liftIO getProcessID
let tmpfile = tmp </> "add" ++ show pid ++ "." ++ takeFileName file
- nuke tmpfile
+ liftIO $ nukeFile tmpfile
liftIO $ createLink file tmpfile
return tmpfile
-nuke :: FilePath -> Annex ()
-nuke file = liftIO $ whenM (doesFileExist file) $ removeFile file
-
{- Moves the file into the annex. -}
ingest :: FilePath -> Annex (Maybe Key)
ingest file = do
@@ -75,7 +72,7 @@ ingest file = do
go _ Nothing = return Nothing
go tmpfile (Just (key, _)) = do
handle (undo file key) $ moveAnnex key tmpfile
- nuke file
+ liftIO $ nukeFile file
return $ Just key
perform :: FilePath -> CommandPerform
@@ -86,7 +83,7 @@ perform file = maybe stop (\key -> next $ cleanup file key True) =<< ingest file
undo :: FilePath -> Key -> IOException -> Annex a
undo file key e = do
whenM (inAnnex key) $ do
- nuke file
+ liftIO $ nukeFile file
handle tryharder $ fromAnnex key file
logStatus key InfoMissing
throw e
diff --git a/Command/DropUnused.hs b/Command/DropUnused.hs
index a94c2873d..597a4eec0 100644
--- a/Command/DropUnused.hs
+++ b/Command/DropUnused.hs
@@ -40,5 +40,5 @@ perform key = maybe droplocal dropremote =<< Remote.byName =<< from
performOther :: (Key -> Git.Repo -> FilePath) -> Key -> CommandPerform
performOther filespec key = do
f <- fromRepo $ filespec key
- liftIO $ whenM (doesFileExist f) $ removeFile f
+ liftIO $ nukeFile f
next $ return True