factored out getViaTmp
This commit is contained in:
parent
fcd30ce992
commit
4c7248c779
1 changed files with 18 additions and 0 deletions
18
Core.hs
18
Core.hs
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue