aboutsummaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-02-07 15:10:41 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-02-07 15:10:41 -0400
commitc8d5b2067037ecb56c06cd1cc32f248c463ed228 (patch)
tree970d8d0a20d6670e8818ea6b733d96065c92ef95 /Command
parentdc0f824c1bc4c9aac1045894983a434eb26196ab (diff)
initremote: When a uuid= parameter is passed, use the specified UUID for the new special remote, instead of generating a UUID.
This can be useful in some situations, eg when the same data can be accessed via two different special remote backends.
Diffstat (limited to 'Command')
-rw-r--r--Command/InitRemote.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/Command/InitRemote.hs b/Command/InitRemote.hs
index 4a89bed7c..78a1738d5 100644
--- a/Command/InitRemote.hs
+++ b/Command/InitRemote.hs
@@ -46,8 +46,14 @@ start (name:ws) = ifM (isJust <$> findExisting name)
perform :: RemoteType -> String -> R.RemoteConfig -> CommandPerform
perform t name c = do
- (c', u) <- R.setup t R.Init Nothing Nothing c def
+ (c', u) <- R.setup t R.Init cu Nothing c def
next $ cleanup u name c'
+ where
+ cu = case M.lookup "uuid" c of
+ Just s
+ | isUUID s -> Just (toUUID s)
+ | otherwise -> giveup "invalid uuid"
+ Nothing -> Nothing
cleanup :: UUID -> String -> R.RemoteConfig -> CommandCleanup
cleanup u name c = do