reinject --known: Avoid second, unncessary checksum of file.

This commit is contained in:
Joey Hess 2016-11-07 12:07:36 -04:00
parent 5343544822
commit 5afc2eaa54
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
3 changed files with 25 additions and 5 deletions

View file

@ -10,6 +10,7 @@ git-annex (6.20161032) UNRELEASED; urgency=medium
* S3: Support the special case endpoint needed for the cn-north-1 region. * S3: Support the special case endpoint needed for the cn-north-1 region.
* Webapp: Don't list the Frankfurt region, as this (and some other new * Webapp: Don't list the Frankfurt region, as this (and some other new
regions) need V4 authorization which the aws library does not yet use. regions) need V4 authorization which the aws library does not yet use.
* reinject --known: Avoid second, unncessary checksum of file.
-- Joey Hess <id@joeyh.name> Tue, 01 Nov 2016 14:02:06 -0400 -- Joey Hess <id@joeyh.name> Tue, 01 Nov 2016 14:02:06 -0400

View file

@ -45,7 +45,7 @@ startSrcDest (src:dest:[])
| otherwise = notAnnexed src $ do | otherwise = notAnnexed src $ do
showStart "reinject" dest showStart "reinject" dest
next $ ifAnnexed dest next $ ifAnnexed dest
(perform src) (\key -> perform src key (verifyKeyContent DefaultVerify UnVerified key src))
stop stop
startSrcDest _ = error "specify a src file and a dest file" startSrcDest _ = error "specify a src file and a dest file"
@ -56,7 +56,7 @@ startKnown src = notAnnexed src $ do
case mkb of case mkb of
Nothing -> error "Failed to generate key" Nothing -> error "Failed to generate key"
Just (key, _) -> ifM (isKnownKey key) Just (key, _) -> ifM (isKnownKey key)
( next $ perform src key ( next $ perform src key (return True)
, do , do
warning "Not known content; skipping" warning "Not known content; skipping"
next $ next $ return True next $ next $ return True
@ -65,14 +65,14 @@ startKnown src = notAnnexed src $ do
notAnnexed :: FilePath -> CommandStart -> CommandStart notAnnexed :: FilePath -> CommandStart -> CommandStart
notAnnexed src = ifAnnexed src (error $ "cannot used annexed file as src: " ++ src) notAnnexed src = ifAnnexed src (error $ "cannot used annexed file as src: " ++ src)
perform :: FilePath -> Key -> CommandPerform perform :: FilePath -> Key -> Annex Bool -> CommandPerform
perform src key = ifM move perform src key verify = ifM move
( next $ cleanup key ( next $ cleanup key
, error "failed" , error "failed"
) )
where where
move = checkDiskSpaceToGet key False $ move = checkDiskSpaceToGet key False $
ifM (verifyKeyContent DefaultVerify UnVerified key src) ifM verify
( do ( do
moveAnnex key src moveAnnex key src
return True return True

View file

@ -0,0 +1,19 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2016-11-07T16:02:28Z"
content="""
What turns out to have been going on here is the file was first checksummed
silently to get the key and see if it is --known,
and then checksummed a second time (with the message displayed) as part of
the reinject process.
So, the second checksum is not needed in --known mode and I've made it not
be done.
It might be that the "(checksum)" message should be displayed during the
intial checksum of the file. git-annex used to always say when it
checksummed, but [[!commit 64160a96795d03ee791faa4757057200934687bc]] got
rid of that in most cases. I guess that "reinject bigfile <13 minute wait> ok"
is acceptable output though.
"""]]