be stricter about rejecting invalid configurations for remotes
This is a first step toward that goal, using the ProposedAccepted type in RemoteConfig lets initremote/enableremote reject bad parameters that were passed in a remote's configuration, while avoiding enableremote rejecting bad parameters that have already been stored in remote.log This does not eliminate every place where a remote config is parsed and a default value is used if the parse false. But, I did fix several things that expected foo=yes/no and so confusingly accepted foo=true but treated it like foo=no. There are still some fields that are parsed with yesNo but not not checked when initializing a remote, and there are other fields that are parsed in other ways and not checked when initializing a remote. This also lays groundwork for rejecting unknown/typoed config keys.
This commit is contained in:
parent
ea3f206fd1
commit
71ecfbfccf
45 changed files with 395 additions and 224 deletions
|
@ -26,6 +26,7 @@ import Assistant.Sync
|
|||
import Config.Cost
|
||||
import Utility.NotificationBroadcaster
|
||||
import qualified Git
|
||||
import Types.ProposedAccepted
|
||||
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.Set as S
|
||||
|
@ -175,7 +176,7 @@ repoList reposelector
|
|||
selectedremote (Just (iscloud, _))
|
||||
| onlyCloud reposelector = iscloud
|
||||
| otherwise = True
|
||||
findinfo m g u = case getconfig "type" of
|
||||
findinfo m g u = case fromProposedAccepted <$> getconfig (Accepted "type") of
|
||||
Just "rsync" -> val True EnableRsyncR
|
||||
Just "directory" -> val False EnableDirectoryR
|
||||
#ifdef WITH_S3
|
||||
|
@ -188,12 +189,12 @@ repoList reposelector
|
|||
Just "gcrypt" ->
|
||||
-- Skip gcrypt repos on removable drives;
|
||||
-- handled separately.
|
||||
case getconfig "gitrepo" of
|
||||
case fromProposedAccepted <$> getconfig (Accepted "gitrepo") of
|
||||
Just rr | remoteLocationIsUrl (parseRemoteLocation rr g) ->
|
||||
val True EnableSshGCryptR
|
||||
_ -> Nothing
|
||||
Just "git" ->
|
||||
case getconfig "location" of
|
||||
case fromProposedAccepted <$> getconfig (Accepted "location") of
|
||||
Just loc | remoteLocationIsSshUrl (parseRemoteLocation loc g) ->
|
||||
val True EnableSshGitRemoteR
|
||||
_ -> Nothing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue