From c8d5b2067037ecb56c06cd1cc32f248c463ed228 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 7 Feb 2017 15:10:41 -0400 Subject: 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. --- Command/InitRemote.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Command/InitRemote.hs') 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 -- cgit v1.2.3