summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
Diffstat (limited to 'Command')
-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