summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-18 17:09:10 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-18 17:26:37 -0400
commit1b90918cec5a649d490a56d6fc8417ca623cbb6a (patch)
tree87c44f3700d811ffee23e3154c145c9d1f9945ea
parentc50a5fbeb4f90041f16cc84bf6b39577655d42b6 (diff)
avoid error message when doing get --from on file not present on remote
-rw-r--r--Command/Get.hs12
-rw-r--r--Command/Move.hs14
2 files changed, 18 insertions, 8 deletions
diff --git a/Command/Get.hs b/Command/Get.hs
index f7d953bb6..093cd2cc5 100644
--- a/Command/Get.hs
+++ b/Command/Get.hs
@@ -27,14 +27,20 @@ start numcopies file (key, _) = do
if inannex
then stop
else autoCopies key (<) numcopies $ do
- showStart "get" file
from <- Annex.getState Annex.fromremote
case from of
- Nothing -> next $ perform key
+ Nothing -> go $ perform key
Just name -> do
-- get --from = copy --from
src <- Remote.byName name
- next $ Command.Move.fromPerform src False key
+ ok <- Command.Move.fromOk src key
+ if ok
+ then go $ Command.Move.fromPerform src False key
+ else stop
+ where
+ go a = do
+ showStart "get" file
+ next a
perform :: Key -> CommandPerform
perform key = do
diff --git a/Command/Move.hs b/Command/Move.hs
index 155f4d605..4c4534c49 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -117,13 +117,17 @@ fromStart src move file key
if ishere then stop else go
where
go = do
- u <- getUUID
- remotes <- Remote.keyPossibilities key
- if u == Remote.uuid src || not (any (== src) remotes)
- then stop
- else do
+ ok <- fromOk src key
+ if ok
+ then do
showMoveAction move file
next $ fromPerform src move key
+ else stop
+fromOk :: Remote.Remote Annex -> Key -> Annex Bool
+fromOk src key = do
+ u <- getUUID
+ remotes <- Remote.keyPossibilities key
+ return $ u /= Remote.uuid src && any (== src) remotes
fromPerform :: Remote.Remote Annex -> Bool -> Key -> CommandPerform
fromPerform src move key = moveLock move key $ do
ishere <- inAnnex key