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.
This commit is contained in:
Joey Hess 2017-02-07 15:10:41 -04:00
parent 5c804cf42e
commit 27e89aeffc
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
4 changed files with 42 additions and 1 deletions

View file

@ -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