summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-25 19:34:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-25 19:34:44 -0400
commita8fbd5d91fc56ebedb08614bb89db2d383c9a0ad (patch)
tree8d456334998530d61c733b08c16fb07868a51453
parente87287c11b81ea6f339628bcbebfb239d0ccadd0 (diff)
speed up git annex move --from
Avoid extra ssh to check if the remote has the key, just trust the location log (and propigate error if it's wrong). Quick exit when asked to move files that are not on the remote, so this is now suitable to be used on a big directory.
-rw-r--r--Commands.hs25
1 files changed, 10 insertions, 15 deletions
diff --git a/Commands.hs b/Commands.hs
index 729eae124..d201b6f79 100644
--- a/Commands.hs
+++ b/Commands.hs
@@ -438,32 +438,27 @@ moveToCleanup remote key = do
-}
moveFromStart :: FilePath -> Annex (Maybe SubCmdPerform)
moveFromStart file = isAnnexed file $ \(key, backend) -> do
- return $ Just $ moveFromPerform file key
+ g <- Annex.gitRepo
+ remote <- Remotes.commandLineRemote
+ l <- Remotes.keyPossibilities key
+ if (elem remote l)
+ then return $ Just $ moveFromPerform file key
+ else return Nothing
moveFromPerform :: FilePath -> Key -> Annex (Maybe SubCmdCleanup)
moveFromPerform file key = do
- -- checking the remote is expensive, so not done in the start step
remote <- Remotes.commandLineRemote
- isthere <- Remotes.inAnnex remote key
ishere <- inAnnex key
- case (ishere, isthere) of
- (_, Left err) -> do
- showNote $ show err
- return Nothing
- (_, Right False) -> do
- showNote $ "not present in " ++ (Git.repoDescribe remote)
- return Nothing
- (False, Right True) -> do
+ if (ishere)
+ then return $ Just $ moveFromCleanup remote key
+ else do
-- copy content from remote
ok <- getViaTmp key (Remotes.copyFromRemote remote key)
if (ok)
then return $ Just $ moveFromCleanup remote key
else return Nothing -- fail
- (True, Right True) -> do
- -- the content is already here, just remove from remote
- return $ Just $ moveFromCleanup remote key
moveFromCleanup :: Git.Repo -> Key -> Annex Bool
moveFromCleanup remote key = do
- -- Force drop content from the remote.
+ showNote $ "dropping from " ++ (Git.repoDescribe remote) ++ "..."
Remotes.runCmd remote "git-annex" ["dropkey", "--quiet", "--force",
"--backend=" ++ (backendName key),
keyName key]