copy --fast --to remote: Avoid printing anything for files that are already believed to be present on the remote.
This commit is contained in:
parent
62018ac879
commit
4cc34973d9
4 changed files with 29 additions and 18 deletions
|
@ -69,20 +69,29 @@ toStart dest move afile key = do
|
|||
ishere <- inAnnex key
|
||||
if not ishere || u == Remote.uuid dest
|
||||
then stop -- not here, so nothing to do
|
||||
else do
|
||||
showMoveAction move key afile
|
||||
next $ toPerform dest move key afile
|
||||
toPerform :: Remote -> Bool -> Key -> AssociatedFile -> CommandPerform
|
||||
toPerform dest move key afile = moveLock move key $ do
|
||||
-- Checking the remote is expensive, so not done in the start step.
|
||||
-- In fast mode, location tracking is assumed to be correct,
|
||||
-- and an explicit check is not done, when copying. When moving,
|
||||
-- it has to be done, to avoid inaverdent data loss.
|
||||
else toStart' dest move afile key
|
||||
|
||||
toStart' :: Remote -> Bool -> AssociatedFile -> Key -> CommandStart
|
||||
toStart' dest move afile key = do
|
||||
fast <- Annex.getState Annex.fast
|
||||
let fastcheck = fast && not move && not (Remote.hasKeyCheap dest)
|
||||
isthere <- if fastcheck
|
||||
then Right <$> expectedpresent
|
||||
else Remote.hasKey dest key
|
||||
if fast && not move && not (Remote.hasKeyCheap dest)
|
||||
then ifM (expectedPresent dest key)
|
||||
( stop
|
||||
, go True (pure $ Right False)
|
||||
)
|
||||
else go False (Remote.hasKey dest key)
|
||||
where
|
||||
go fastcheck isthere = do
|
||||
showMoveAction move key afile
|
||||
next $ toPerform dest move key afile fastcheck =<< isthere
|
||||
|
||||
expectedPresent :: Remote -> Key -> Annex Bool
|
||||
expectedPresent dest key = do
|
||||
remotes <- Remote.keyPossibilities key
|
||||
return $ dest `elem` remotes
|
||||
|
||||
toPerform :: Remote -> Bool -> Key -> AssociatedFile -> Bool -> Either String Bool -> CommandPerform
|
||||
toPerform dest move key afile fastcheck isthere = moveLock move key $
|
||||
case isthere of
|
||||
Left err -> do
|
||||
showNote err
|
||||
|
@ -100,7 +109,7 @@ toPerform dest move key afile = moveLock move key $ do
|
|||
warning "This could have failed because --fast is enabled."
|
||||
stop
|
||||
Right True -> do
|
||||
unlessM expectedpresent $
|
||||
unlessM (expectedPresent dest key) $
|
||||
Remote.logStatus dest key InfoPresent
|
||||
finish
|
||||
where
|
||||
|
@ -109,9 +118,6 @@ toPerform dest move key afile = moveLock move key $ do
|
|||
removeAnnex key
|
||||
next $ Command.Drop.cleanupLocal key
|
||||
| otherwise = next $ return True
|
||||
expectedpresent = do
|
||||
remotes <- Remote.keyPossibilities key
|
||||
return $ dest `elem` remotes
|
||||
|
||||
{- Moves (or copies) the content of an annexed file from a remote
|
||||
- to the current repository.
|
||||
|
|
|
@ -376,5 +376,5 @@ syncFile rs f (k, _) = do
|
|||
put dest = do
|
||||
ok <- commandAction $ do
|
||||
showStart "copy" f
|
||||
next $ Command.Move.toPerform dest False k (Just f)
|
||||
Command.Move.toStart' dest False (Just f) k
|
||||
return (ok, if ok then Just (Remote.uuid dest) else Nothing)
|
||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -8,6 +8,8 @@ git-annex (5.20140307) UNRELEASED; urgency=medium
|
|||
* repair: Improve memory usage when git fsck finds a great many broken
|
||||
objects.
|
||||
* webapp: Use securemem for constant time auth token comparisons.
|
||||
* copy --fast --to remote: Avoid printing anything for files that
|
||||
are already believed to be present on the remote.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Thu, 06 Mar 2014 16:17:01 -0400
|
||||
|
||||
|
|
|
@ -23,3 +23,6 @@ No information whatsoever is printed during upload when ran without `--quite` it
|
|||
"""]]
|
||||
|
||||
[[!meta title="copy --fast --to remote should be quiet when nothing to do"]]
|
||||
|
||||
> [[fixed|done]]; Avoided the unnecessary output in this situation.
|
||||
> --[[Joey]]
|
||||
|
|
Loading…
Add table
Reference in a new issue