From 6149a3b9bdb78bb879b9c5fc8438c144db083755 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 8 Mar 2019 12:43:03 -0400 Subject: [PATCH] added progress bars clean up old todo item I checked earlier, see commit dec30d2b14375b31f0cc259b12004654990d2d0d --- Annex/Import.hs | 31 ++++++++++++++++--------------- doc/todo/import_tree.mdwn | 6 ------ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/Annex/Import.hs b/Annex/Import.hs index f48c5d078f..87d4fdf626 100644 --- a/Annex/Import.hs +++ b/Annex/Import.hs @@ -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 diff --git a/doc/todo/import_tree.mdwn b/doc/todo/import_tree.mdwn index 7aca7d7bcc..7192822a5f 100644 --- a/doc/todo/import_tree.mdwn +++ b/doc/todo/import_tree.mdwn @@ -13,8 +13,6 @@ this. * Need to support annex-tracking-branch configuration, which documentation says makes git-annex sync and assistant do imports. -* progress bars when downloading from import - * When on an adjusted unlocked branch, need to import the files unlocked. Also, the tracking branch code needs to know about such branches, currently it will generate the wrong tracking branch. @@ -30,10 +28,6 @@ this. (like eg a way to merge a specified branch and update the adjustment) would thus benefit both uses cases. -* What if the remote lists importable filenames that are absolute paths, - or contain a "../" attack? Does git already guard against merging such - trees? - * Need to support annex.largefiles when importing. * If a tree containing a non-annexed file is exported,