move --to=here
* move --to=here moves from all reachable remotes to the local repository. The output of move --from remote is changed slightly, when the remote and local both have the content. It used to say: move foo ok Now: move foo (from theremote...) ok That was done so that, when move --to=here is used and the content is locally present and also in several remotes, it's clear which remotes the content gets dropped from. Note that move --to=here will report an error if a non-reachable remote contains the file, even if the local repository also contains the file. I think that's reasonable; the user may be intending to move all other copies of the file from remotes. OTOH, if a copy of the file is believed to be present in some repository that is not a configured remote, move --to=here does not report an error. So a little bit inconsistent, but erroring in this case feels wrong. copy --to=here came along for free, but it's basically the same behavior as git-annex get, and probably with not as good messages in edge cases (especially on failure), so I've not documented it. This commit was sponsored by Anthony DeRobertis on Patreon.
This commit is contained in:
parent
5ee6912cf3
commit
bb18026b2c
5 changed files with 46 additions and 18 deletions
|
@ -1,5 +1,6 @@
|
|||
git-annex (6.20170520) UNRELEASED; urgency=medium
|
||||
|
||||
* move --to=here moves from all reachable remotes to the local repository.
|
||||
* initremote, enableremote: Support gpg subkeys suffixed with an
|
||||
exclamation mark, which forces gpg to use a specific subkey.
|
||||
* Improve progress display when watching file size, in cases where
|
||||
|
|
|
@ -52,7 +52,10 @@ start o file key = stopUnless shouldCopy $
|
|||
| autoMode o = want <||> numCopiesCheck file key (<)
|
||||
| otherwise = return True
|
||||
want = case Command.Move.fromToOptions (moveOptions o) of
|
||||
Right (ToRemote dest) -> (Remote.uuid <$> getParsed dest) >>=
|
||||
wantSend False (Just key) (AssociatedFile (Just file))
|
||||
Right (FromRemote _) ->
|
||||
wantGet False (Just key) (AssociatedFile (Just file))
|
||||
Right (ToRemote dest) ->
|
||||
(Remote.uuid <$> getParsed dest) >>= checkwantsend
|
||||
Right (FromRemote _) -> checkwantget
|
||||
Left Command.Move.ToHere -> checkwantget
|
||||
|
||||
checkwantsend = wantSend False (Just key) (AssociatedFile (Just file))
|
||||
checkwantget = wantGet False (Just key) (AssociatedFile (Just file))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2010-2015 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2017 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
@ -75,6 +75,9 @@ start' o move afile key ai =
|
|||
Right (ToRemote dest) ->
|
||||
checkFailedTransferDirection ai Upload $
|
||||
toStart move afile key ai =<< getParsed dest
|
||||
Left ToHere ->
|
||||
checkFailedTransferDirection ai Download $
|
||||
toHereStart move afile key ai
|
||||
|
||||
showMoveAction :: Bool -> Key -> ActionItem -> Annex ()
|
||||
showMoveAction move = showStart' (if move then "move" else "copy")
|
||||
|
@ -181,14 +184,15 @@ fromOk src key = go =<< Annex.getState Annex.force
|
|||
return $ u /= Remote.uuid src && elem src remotes
|
||||
|
||||
fromPerform :: Remote -> Bool -> Key -> AssociatedFile -> CommandPerform
|
||||
fromPerform src move key afile = ifM (inAnnex key)
|
||||
( dispatch move True
|
||||
, dispatch move =<< go
|
||||
)
|
||||
fromPerform src move key afile = do
|
||||
showAction $ "from " ++ Remote.name src
|
||||
ifM (inAnnex key)
|
||||
( dispatch move True
|
||||
, dispatch move =<< go
|
||||
)
|
||||
where
|
||||
go = notifyTransfer Download afile $
|
||||
download (Remote.uuid src) key afile forwardRetry $ \p -> do
|
||||
showAction $ "from " ++ Remote.name src
|
||||
download (Remote.uuid src) key afile forwardRetry $ \p ->
|
||||
getViaTmp (RemoteVerify src) key $ \t ->
|
||||
Remote.retrieveKeyFile src key afile t p
|
||||
dispatch _ False = stop -- failed
|
||||
|
@ -208,3 +212,20 @@ fromPerform src move key afile = ifM (inAnnex key)
|
|||
ok <- Remote.removeKey src key
|
||||
next $ Command.Drop.cleanupRemote key src ok
|
||||
faileddropremote = giveup "Unable to drop from remote."
|
||||
|
||||
{- Moves (or copies) the content of an annexed file from reachable remotes
|
||||
- to the current repository.
|
||||
-
|
||||
- When moving, the content is removed from all the reachable remotes. -}
|
||||
toHereStart :: Bool -> AssociatedFile -> Key -> ActionItem -> CommandStart
|
||||
toHereStart move afile key ai
|
||||
| move = go
|
||||
| otherwise = stopUnless (not <$> inAnnex key) go
|
||||
where
|
||||
go = do
|
||||
rs <- Remote.keyPossibilities key
|
||||
forM_ rs $ \r ->
|
||||
includeCommandAction $ do
|
||||
showMoveAction move key ai
|
||||
next $ fromPerform r move key afile
|
||||
stop
|
||||
|
|
|
@ -14,14 +14,14 @@ Copies the content of files from or to another remote.
|
|||
|
||||
* `--from=remote`
|
||||
|
||||
Use this option to copy the content of files from the specified
|
||||
Copy the content of files from the specified
|
||||
remote to the local repository.
|
||||
|
||||
Any files that are not available on the remote will be silently skipped.
|
||||
|
||||
* `--to=remote`
|
||||
|
||||
Use this option to copy the content of files from the local repository
|
||||
Copy the content of files from the local repository
|
||||
to the specified remote.
|
||||
|
||||
* `--jobs=N` `-JN`
|
||||
|
|
|
@ -4,7 +4,7 @@ git-annex move - move content of files to/from another repository
|
|||
|
||||
# SYNOPSIS
|
||||
|
||||
git annex move `[path ...] [--from=remote|--to=remote]`
|
||||
git annex move `[path ...] [--from=remote|--to=remote|--to=here]`
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
|
@ -14,13 +14,16 @@ Moves the content of files from or to another remote.
|
|||
|
||||
* `--from=remote`
|
||||
|
||||
Use this option to move the content of files from the specified
|
||||
remote to the local repository.
|
||||
Move the content of files from the specified remote to the local repository.
|
||||
|
||||
* `--to=remote`
|
||||
|
||||
Use this option to move the content of files from the local repository
|
||||
to the specified remote.
|
||||
Move the content of files from the local repository to the specified remote.
|
||||
|
||||
* `--to=here`
|
||||
|
||||
Move the content of files from all reachable remotes to the local
|
||||
repository.
|
||||
|
||||
* `--jobs=N` `-JN`
|
||||
|
||||
|
|
Loading…
Reference in a new issue