atomic file retrieval from backends

This commit is contained in:
Joey Hess 2010-10-17 16:39:30 -04:00
parent 8398b9ab4a
commit a020b0c25c
4 changed files with 22 additions and 10 deletions

View file

@ -156,13 +156,16 @@ getCmd file = notinBackend file err $ \(key, backend) -> do
showStart "get" file
g <- Annex.gitRepo
let dest = annexLocation g key
liftIO $ createDirectoryIfMissing True (parentDir dest)
success <- Backend.retrieveKeyFile backend key dest
let tmp = (annexTmpLocation g) ++ (keyFile key)
liftIO $ createDirectoryIfMissing True (parentDir tmp)
success <- Backend.retrieveKeyFile backend key tmp
if (success)
then do
liftIO $ renameFile tmp dest
logStatus key ValuePresent
showEndOk
else showEndFail "get" file
else do
showEndFail "get" file
where
err = error $ "not annexed " ++ file