diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-23 14:26:38 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-23 14:26:38 -0400 |
commit | 4c7248c77998d011f8978a32328b8f3817d7acbc (patch) | |
tree | f52ebc32c37387fe72e97c2b655f916ed8bc2796 /Core.hs | |
parent | fcd30ce99251cf8bd98ab25fb73f1fcb5b081a4c (diff) |
factored out getViaTmp
Diffstat (limited to 'Core.hs')
-rw-r--r-- | Core.hs | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -94,6 +94,24 @@ logStatus key status = do u <- getUUID g liftIO $ logChange g key u status +{- Runs an action, passing it a temporary filename to download, + - and if the action succeeds, moves the temp file into + - the annex as a key's content. -} +getViaTmp :: Key -> (FilePath -> Annex (Bool)) -> Annex () +getViaTmp key action = do + g <- Annex.gitRepo + let dest = annexLocation g key + let tmp = (annexTmpLocation g) ++ (keyFile key) + liftIO $ createDirectoryIfMissing True (parentDir tmp) + success <- action tmp + if (success) + then do + liftIO $ renameFile tmp dest + logStatus key ValuePresent + showEndOk + else do + showEndFail + {- Output logging -} showStart :: String -> String -> Annex () showStart command file = do |