webapp: Ensure that rsync special remotes are enabled using the same name they were originally created using.

It was creating a new special remote with a different name, unless
the stars perfectly aligned and the names matched.
This commit is contained in:
Joey Hess 2012-10-31 16:14:52 -04:00
parent 39e82b1af8
commit 33dbb19d99
2 changed files with 15 additions and 11 deletions

View file

@ -122,22 +122,23 @@ getAddSshR = sshConfigurator $ do
-} -}
getEnableRsyncR :: UUID -> Handler RepHtml getEnableRsyncR :: UUID -> Handler RepHtml
getEnableRsyncR u = do getEnableRsyncR u = do
m <- runAnnex M.empty readRemoteLog m <- fromMaybe M.empty . M.lookup u <$> runAnnex M.empty readRemoteLog
case parseSshRsyncUrl =<< M.lookup "rsyncurl" =<< M.lookup u m of case (parseSshRsyncUrl =<< M.lookup "rsyncurl" m, M.lookup "name" m) of
Nothing -> redirect AddSshR (Just sshinput, Just reponame) -> sshConfigurator $ do
Just sshinput -> sshConfigurator $ do
((result, form), enctype) <- lift $ ((result, form), enctype) <- lift $
runFormGet $ renderBootstrap $ sshInputAForm sshinput runFormGet $ renderBootstrap $ sshInputAForm sshinput
case result of case result of
FormSuccess sshinput' FormSuccess sshinput'
| isRsyncNet (hostname sshinput') -> | isRsyncNet (hostname sshinput') ->
void $ lift $ makeRsyncNet sshinput' (const noop) void $ lift $ makeRsyncNet sshinput' reponame (const noop)
| otherwise -> do | otherwise -> do
s <- liftIO $ testServer sshinput' s <- liftIO $ testServer sshinput'
case s of case s of
Left status -> showform form enctype status Left status -> showform form enctype status
Right sshdata -> enable sshdata Right sshdata -> enable sshdata
{ sshRepoName = reponame }
_ -> showform form enctype UntestedServer _ -> showform form enctype UntestedServer
_ -> redirect AddSshR
where where
showform form enctype status = do showform form enctype status = do
description <- lift $ runAnnex "" $ description <- lift $ runAnnex "" $
@ -297,21 +298,22 @@ getAddRsyncNetR = do
$(widgetFile "configurators/addrsync.net") $(widgetFile "configurators/addrsync.net")
case result of case result of
FormSuccess sshinput FormSuccess sshinput
| isRsyncNet (hostname sshinput) -> | isRsyncNet (hostname sshinput) -> do
makeRsyncNet sshinput setupGroup let reponame = genSshRepoName "rsync.net"
(maybe "" T.unpack $ directory sshinput)
makeRsyncNet sshinput reponame setupGroup
| otherwise -> | otherwise ->
showform $ UnusableServer showform $ UnusableServer
"That is not a rsync.net host name." "That is not a rsync.net host name."
_ -> showform UntestedServer _ -> showform UntestedServer
makeRsyncNet :: SshInput -> (Remote -> Handler ()) -> Handler RepHtml makeRsyncNet :: SshInput -> String -> (Remote -> Handler ()) -> Handler RepHtml
makeRsyncNet sshinput setup = do makeRsyncNet sshinput reponame setup = do
knownhost <- liftIO $ maybe (return False) knownHost (hostname sshinput) knownhost <- liftIO $ maybe (return False) knownHost (hostname sshinput)
keypair <- liftIO $ genSshKeyPair keypair <- liftIO $ genSshKeyPair
sshdata <- liftIO $ setupSshKeyPair keypair $ sshdata <- liftIO $ setupSshKeyPair keypair $
(mkSshData sshinput) (mkSshData sshinput)
{ sshRepoName = genSshRepoName "rsync.net" { sshRepoName = reponame
(maybe "" T.unpack $ directory sshinput)
, needsPubKey = True , needsPubKey = True
, rsyncOnly = True , rsyncOnly = True
} }

2
debian/changelog vendored
View file

@ -38,6 +38,8 @@ git-annex (3.20121018) UNRELEASED; urgency=low
* webapp: Fix creation of rsync.net repositories. * webapp: Fix creation of rsync.net repositories.
* webapp: Fix renaming of special remotes. * webapp: Fix renaming of special remotes.
* webapp: Generate better git remote names. * webapp: Generate better git remote names.
* webapp: Ensure that rsync special remotes are enabled using the same
name they were originally created using.
-- Joey Hess <joeyh@debian.org> Wed, 17 Oct 2012 14:24:10 -0400 -- Joey Hess <joeyh@debian.org> Wed, 17 Oct 2012 14:24:10 -0400