plumb MeterUpdate into getKey
No behavior changes, but this shows everywhere that a progress meter could be displayed when hashing a file to add to the annex. Many of the places don't make sense to display a progress meter though, eg when importing the copy of the file probably swamps the hashing of the file.
This commit is contained in:
parent
191bdaafc5
commit
8355dba5cc
18 changed files with 60 additions and 44 deletions
|
@ -21,6 +21,7 @@ import Annex.Link
|
|||
import Annex.Version
|
||||
import Annex.Tmp
|
||||
import Git.FilePath
|
||||
import Utility.Metered
|
||||
|
||||
cmd :: Command
|
||||
cmd = notBareRepo $
|
||||
|
@ -141,7 +142,7 @@ perform file = withOtherTmp $ \tmpdir -> do
|
|||
{ lockingFile = lockingfile
|
||||
, hardlinkFileTmpDir = Just tmpdir
|
||||
}
|
||||
lockDown cfg file >>= ingestAdd >>= finish
|
||||
lockDown cfg file >>= ingestAdd nullMeterUpdate >>= finish
|
||||
where
|
||||
finish (Just key) = next $ cleanup key True
|
||||
finish Nothing = stop
|
||||
|
|
|
@ -372,7 +372,7 @@ finishDownloadWith tmp u url file = do
|
|||
, contentLocation = tmp
|
||||
, inodeCache = Nothing
|
||||
}
|
||||
genKey source backend >>= \case
|
||||
genKey source nullMeterUpdate backend >>= \case
|
||||
Nothing -> return Nothing
|
||||
Just (key, _) -> do
|
||||
addWorkTree u url file key (Just tmp)
|
||||
|
|
|
@ -10,6 +10,7 @@ module Command.CalcKey where
|
|||
import Command
|
||||
import Backend (genKey)
|
||||
import Types.KeySource
|
||||
import Utility.Metered
|
||||
|
||||
cmd :: Command
|
||||
cmd = noCommit $ noMessages $ dontCheck repoExists $
|
||||
|
@ -19,7 +20,7 @@ cmd = noCommit $ noMessages $ dontCheck repoExists $
|
|||
(batchable run (pure ()))
|
||||
|
||||
run :: () -> String -> Annex Bool
|
||||
run _ file = genKey (KeySource file file Nothing) Nothing >>= \case
|
||||
run _ file = genKey (KeySource file file Nothing) nullMeterUpdate Nothing >>= \case
|
||||
Just (k, _) -> do
|
||||
liftIO $ putStrLn $ serializeKey k
|
||||
return True
|
||||
|
|
|
@ -32,6 +32,7 @@ import Git.FilePath
|
|||
import Git.Types
|
||||
import Git.Branch
|
||||
import Types.Import
|
||||
import Utility.Metered
|
||||
|
||||
import Control.Concurrent.STM
|
||||
|
||||
|
@ -198,7 +199,7 @@ startLocal largematcher mode (srcfile, destfile) =
|
|||
}
|
||||
}
|
||||
ifM (checkFileMatcher largematcher destfile)
|
||||
( ingestAdd' (Just ld') (Just k)
|
||||
( ingestAdd' nullMeterUpdate (Just ld') (Just k)
|
||||
>>= maybe
|
||||
stop
|
||||
(\addedk -> next $ Command.Add.cleanup addedk True)
|
||||
|
@ -219,7 +220,7 @@ startLocal largematcher mode (srcfile, destfile) =
|
|||
case v of
|
||||
Just ld -> do
|
||||
backend <- chooseBackend destfile
|
||||
v' <- genKey (keySource ld) backend
|
||||
v' <- genKey (keySource ld) nullMeterUpdate backend
|
||||
case v' of
|
||||
Just (k, _) -> a (ld, k)
|
||||
Nothing -> giveup "failed to generate a key"
|
||||
|
|
|
@ -17,6 +17,7 @@ import qualified Command.Fsck
|
|||
import qualified Annex
|
||||
import Logs.MetaData
|
||||
import Logs.Web
|
||||
import Utility.Metered
|
||||
|
||||
cmd :: Command
|
||||
cmd = notDirect $ withGlobalOptions [annexedMatchingOptions] $
|
||||
|
@ -88,7 +89,7 @@ perform file oldkey oldbackend newbackend = go =<< genkey (fastMigrate oldbacken
|
|||
, contentLocation = content
|
||||
, inodeCache = Nothing
|
||||
}
|
||||
v <- genKey source (Just newbackend)
|
||||
v <- genKey source nullMeterUpdate (Just newbackend)
|
||||
return $ case v of
|
||||
Just (newkey, _) -> Just (newkey, False)
|
||||
_ -> Nothing
|
||||
|
|
|
@ -12,6 +12,7 @@ import Logs.Location
|
|||
import Annex.Content
|
||||
import Backend
|
||||
import Types.KeySource
|
||||
import Utility.Metered
|
||||
|
||||
cmd :: Command
|
||||
cmd = command "reinject" SectionUtility
|
||||
|
@ -53,7 +54,7 @@ startSrcDest _ = giveup "specify a src file and a dest file"
|
|||
startKnown :: FilePath -> CommandStart
|
||||
startKnown src = notAnnexed src $
|
||||
starting "reinject" (ActionItemOther (Just src)) $ do
|
||||
mkb <- genKey (KeySource src src Nothing) Nothing
|
||||
mkb <- genKey (KeySource src src Nothing) nullMeterUpdate Nothing
|
||||
case mkb of
|
||||
Nothing -> error "Failed to generate key"
|
||||
Just (key, _) -> ifM (isKnownKey key)
|
||||
|
|
|
@ -21,6 +21,7 @@ import Git.FilePath
|
|||
import qualified Git
|
||||
import qualified Git.Ref
|
||||
import Backend
|
||||
import Utility.Metered
|
||||
|
||||
import qualified Data.ByteString as S
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
|
@ -122,7 +123,7 @@ clean file = do
|
|||
let norestage = Restage False
|
||||
liftIO . emitPointer
|
||||
=<< postingest
|
||||
=<< (\ld -> ingest' oldbackend ld Nothing norestage)
|
||||
=<< (\ld -> ingest' oldbackend nullMeterUpdate ld Nothing norestage)
|
||||
=<< lockDown cfg file
|
||||
|
||||
postingest (Just k, _) = do
|
||||
|
|
|
@ -320,7 +320,7 @@ randKey sz = withTmpFile "randkey" $ \f h -> do
|
|||
, inodeCache = Nothing
|
||||
}
|
||||
k <- fromMaybe (error "failed to generate random key")
|
||||
<$> Backend.getKey Backend.Hash.testKeyBackend ks
|
||||
<$> Backend.getKey Backend.Hash.testKeyBackend ks nullMeterUpdate
|
||||
_ <- moveAnnex k f
|
||||
return k
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue