diff options
author | Joey Hess <joey@kitenet.net> | 2012-06-06 13:13:13 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-06-06 13:13:13 -0400 |
commit | 993e6459a38817a9062aafae7552a668c2db7a31 (patch) | |
tree | 900b38c923644d9f8b7eaf92ec240aa610551780 /Command/Add.hs | |
parent | 723eb19bbf30d502cb6979655b8013de49ce0b5e (diff) |
factor out nukeFile
Diffstat (limited to 'Command/Add.hs')
-rw-r--r-- | Command/Add.hs | 9 |
1 files changed, 3 insertions, 6 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 |