rename function

This commit is contained in:
Joey Hess 2015-10-01 14:13:53 -04:00
parent 807ba6a903
commit b72d3fbeba
3 changed files with 15 additions and 16 deletions

View file

@ -14,8 +14,8 @@ module Annex.Content (
inAnnexCheck, inAnnexCheck,
lockContent, lockContent,
getViaTmp, getViaTmp,
getViaTmpUnchecked, getViaTmp',
prepGetViaTmpChecked, checkDiskSpaceToGet,
prepTmp, prepTmp,
withTmp, withTmp,
checkDiskSpace, checkDiskSpace,
@ -211,18 +211,17 @@ lockContent key a = do
maybe noop cleanuplockfile mlockfile maybe noop cleanuplockfile mlockfile
#endif #endif
{- Runs an action, passing it a temporary filename to get, {- Runs an action, passing it the temp file to get,
- and if the action succeeds, verifies the file matches the key and - and if the action succeeds, verifies the file matches
- moves the file into the annex as a key's content. -} - the key and moves the file into the annex as a key's content. -}
getViaTmp :: Key -> (FilePath -> Annex Bool) -> Annex Bool getViaTmp :: Key -> (FilePath -> Annex Bool) -> Annex Bool
getViaTmp key action = prepGetViaTmpChecked key False $ getViaTmp key action = checkDiskSpaceToGet key False $ getViaTmp' key action
getViaTmpUnchecked key action
{- Like getViaTmp, but does not check that there is enough disk space {- Like getViaTmp, but does not check that there is enough disk space
- for the incoming key. For use when the key content is already on disk - for the incoming key. For use when the key content is already on disk
- and not being copied into place. -} - and not being copied into place. -}
getViaTmpUnchecked :: Key -> (FilePath -> Annex Bool) -> Annex Bool getViaTmp' :: Key -> (FilePath -> Annex Bool) -> Annex Bool
getViaTmpUnchecked key action = do getViaTmp' key action = do
tmpfile <- prepTmp key tmpfile <- prepTmp key
ifM (action tmpfile) ifM (action tmpfile)
( do ( do
@ -234,16 +233,16 @@ getViaTmpUnchecked key action = do
, return False , return False
) )
{- Prepares to download a key via a tmp file, and checks that there is {- Checks if there is enough free disk space to download a key
- enough free disk space. - to its temp file.
- -
- When the temp file already exists, count the space it is using as - When the temp file already exists, count the space it is using as
- free, since the download will overwrite it or resume. - free, since the download will overwrite it or resume.
- -
- Wen there's enough free space, runs the download action. - Wen there's enough free space, runs the download action.
-} -}
prepGetViaTmpChecked :: Key -> a -> Annex a -> Annex a checkDiskSpaceToGet :: Key -> a -> Annex a -> Annex a
prepGetViaTmpChecked key unabletoget getkey = do checkDiskSpaceToGet key unabletoget getkey = do
tmp <- fromRepo $ gitAnnexTmpObjectLocation key tmp <- fromRepo $ gitAnnexTmpObjectLocation key
e <- liftIO $ doesFileExist tmp e <- liftIO $ doesFileExist tmp

View file

@ -247,7 +247,7 @@ addUrlFileQuvi relaxed quviurl videourl file = do
- it later. -} - it later. -}
urlinfo <- Url.withUrlOptions (Url.getUrlInfo videourl) urlinfo <- Url.withUrlOptions (Url.getUrlInfo videourl)
let sizedkey = addSizeUrlKey urlinfo key let sizedkey = addSizeUrlKey urlinfo key
prepGetViaTmpChecked sizedkey Nothing $ do checkDiskSpaceToGet sizedkey Nothing $ do
tmp <- fromRepo $ gitAnnexTmpObjectLocation key tmp <- fromRepo $ gitAnnexTmpObjectLocation key
showOutput showOutput
ok <- Transfer.notifyTransfer Transfer.Download (Just file) $ ok <- Transfer.notifyTransfer Transfer.Download (Just file) $
@ -305,7 +305,7 @@ downloadWeb url urlinfo file = do
- stable. -} - stable. -}
downloadWith :: (FilePath -> MeterUpdate -> Annex Bool) -> Key -> UUID -> URLString -> FilePath -> Annex (Maybe Key) downloadWith :: (FilePath -> MeterUpdate -> Annex Bool) -> Key -> UUID -> URLString -> FilePath -> Annex (Maybe Key)
downloadWith downloader dummykey u url file = downloadWith downloader dummykey u url file =
prepGetViaTmpChecked dummykey Nothing $ do checkDiskSpaceToGet dummykey Nothing $ do
tmp <- fromRepo $ gitAnnexTmpObjectLocation dummykey tmp <- fromRepo $ gitAnnexTmpObjectLocation dummykey
ifM (runtransfer tmp) ifM (runtransfer tmp)
( do ( do

View file

@ -52,7 +52,7 @@ perform file oldkey newkey = do
{- Make a hard link to the old key content (when supported), {- Make a hard link to the old key content (when supported),
- to avoid wasting disk space. -} - to avoid wasting disk space. -}
linkKey :: Key -> Key -> Annex Bool linkKey :: Key -> Key -> Annex Bool
linkKey oldkey newkey = getViaTmpUnchecked newkey $ \tmp -> do linkKey oldkey newkey = getViaTmp' newkey $ \tmp -> do
src <- calcRepo $ gitAnnexLocation oldkey src <- calcRepo $ gitAnnexLocation oldkey
liftIO $ ifM (doesFileExist tmp) liftIO $ ifM (doesFileExist tmp)
( return True ( return True