diff options
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Content.hs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs index efd360a09..c21ac405e 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -306,9 +306,18 @@ downloadUrl urls file = do {- Copies a key's content, when present, to a temp file. - This is used to speed up some rsyncs. -} -preseedTmp :: Key -> FilePath -> Annex () -preseedTmp key file = - unlessM (liftIO $ doesFileExist file) $ whenM (inAnnex key) $ do - s <- inRepo $ gitAnnexLocation key - liftIO $ whenM (copyFileExternal s file) $ - allowWrite file +preseedTmp :: Key -> FilePath -> Annex Bool +preseedTmp key file = go =<< inAnnex key + where + go False = return False + go True = do + ok <- copy + when ok $ liftIO $ allowWrite file + return ok + copy = do + present <- liftIO $ doesFileExist file + if present + then return True + else do + s <- inRepo $ gitAnnexLocation key + liftIO $ copyFileExternal s file |