added progress bars

clean up old todo item I checked earlier, see commit
dec30d2b14
This commit is contained in:
Joey Hess 2019-03-08 12:43:03 -04:00
parent e412129523
commit 6149a3b9bd
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 16 additions and 21 deletions

View file

@ -35,7 +35,7 @@ import Backend
import Config
import Types.Key
import Types.KeySource
import Utility.Metered
import Messages.Progress
import Utility.DataUnits
import Logs.Export
import Logs.Location
@ -255,7 +255,7 @@ downloadImport remote importtreeconfig importablecontents = do
(k:_) -> return $ Left $ Just (loc, k)
[] -> do
job <- liftIO $ newEmptyTMVarIO
let rundownload = do
let downloadaction = do
showStart "import" (fromImportLocation loc)
next $ tryNonAsync (download cidmap db i) >>= \case
Left e -> next $ do
@ -270,24 +270,25 @@ downloadImport remote importtreeconfig importablecontents = do
commandAction $ bracket_
(waitstart downloading cid)
(signaldone downloading cid)
rundownload
downloadaction
return (Right job)
download cidmap db (loc, (cid, sz)) =
download cidmap db (loc, (cid, sz)) = do
let rundownload tmpfile p =
Remote.retrieveExportWithContentIdentifier ia loc cid tmpfile (mkkey loc tmpfile) p >>= \case
Just k -> tryNonAsync (moveAnnex k tmpfile) >>= \case
Right True -> do
recordcidkey cidmap db cid k
logStatus k InfoPresent
logChange k (Remote.uuid remote) InfoPresent
return $ Just (loc, k)
_ -> return Nothing
Nothing -> return Nothing
checkDiskSpaceToGet tmpkey Nothing $
withTmp tmpkey $ \tmpfile ->
Remote.retrieveExportWithContentIdentifier ia loc cid tmpfile (mkkey loc tmpfile) p >>= \case
Just k -> tryNonAsync (moveAnnex k tmpfile) >>= \case
Right True -> do
recordcidkey cidmap db cid k
logStatus k InfoPresent
logChange k (Remote.uuid remote) InfoPresent
return $ Just (loc, k)
_ -> return Nothing
Nothing -> return Nothing
metered Nothing tmpkey (return Nothing) $
const (rundownload tmpfile)
where
-- TODO progress bar
p = nullMeterUpdate
ia = Remote.importActions remote
tmpkey = importKey cid sz