webapp: avoid overwriting remote configs when enabling it
Avoid stomping on existing group and preferred content settings when enabling or combining with an already existing remote. Two level fix. First, use defaultStandardGroup rather than setStandardGroup, so if there is an existing configuration in the git-annex branch, it's not overwritten. To handle pre-existing ssh remotes (including gcrypt), a second level is needed, because before syncing with the remote, it's configuration won't be available locally. (And syncing could take a long time.) So, in this case, keep track of whether the remote is being created or enabled, and only set configs when creating it. This commit was sponsored by Anders Lannerback.
This commit is contained in:
parent
7089e282b5
commit
9eaabf0382
6 changed files with 52 additions and 29 deletions
|
@ -31,13 +31,15 @@ import Utility.Yesod
|
|||
- This includes displaying the connectionNeeded nudge if appropariate.
|
||||
-}
|
||||
setupCloudRemote :: StandardGroup -> Maybe Cost -> Annex RemoteName -> Handler a
|
||||
setupCloudRemote = setupRemote $ redirect . EditNewCloudRepositoryR . Remote.uuid
|
||||
setupCloudRemote = setupRemote postsetup . Just
|
||||
where
|
||||
postsetup = redirect . EditNewCloudRepositoryR . Remote.uuid
|
||||
|
||||
setupRemote :: (Remote -> Handler a) -> StandardGroup -> Maybe Cost -> Annex RemoteName -> Handler a
|
||||
setupRemote postsetup defaultgroup mcost getname = do
|
||||
setupRemote :: (Remote -> Handler a) -> Maybe StandardGroup -> Maybe Cost -> Annex RemoteName -> Handler a
|
||||
setupRemote postsetup mgroup mcost getname = do
|
||||
r <- liftAnnex $ addRemote getname
|
||||
liftAnnex $ do
|
||||
setStandardGroup (Remote.uuid r) defaultgroup
|
||||
maybe noop (defaultStandardGroup (Remote.uuid r)) mgroup
|
||||
maybe noop (Config.setRemoteCost (Remote.repo r)) mcost
|
||||
liftAssistant $ syncRemote r
|
||||
postsetup r
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue