Make database open attempts configurable also via config file

This commit is contained in:
Frank Steinborn
2019-08-21 13:16:27 +02:00
committed by Andrey Smirnov
parent 586f879e80
commit 98e75f6d97
9 changed files with 27 additions and 2 deletions
+2
View File
@@ -12,6 +12,7 @@ type ConfigStructure struct { // nolint: maligned
DownloadConcurrency int `json:"downloadConcurrency"`
DownloadLimit int64 `json:"downloadSpeedLimit"`
DownloadRetries int `json:"downloadRetries"`
DatabaseOpenAttempts int `json:"databaseOpenAttempts"`
Architectures []string `json:"architectures"`
DepFollowSuggests bool `json:"dependencyFollowSuggests"`
DepFollowRecommends bool `json:"dependencyFollowRecommends"`
@@ -76,6 +77,7 @@ var Config = ConfigStructure{
RootDir: filepath.Join(os.Getenv("HOME"), ".aptly"),
DownloadConcurrency: 4,
DownloadLimit: 0,
DatabaseOpenAttempts: -1,
Architectures: []string{},
DepFollowSuggests: false,
DepFollowRecommends: false,
+4 -1
View File
@@ -23,6 +23,7 @@ func (s *ConfigSuite) TestLoadConfig(c *C) {
c.Assert(err, IsNil)
c.Check(s.config.RootDir, Equals, "/opt/aptly/")
c.Check(s.config.DownloadConcurrency, Equals, 33)
c.Check(s.config.DatabaseOpenAttempts, Equals, 33)
}
func (s *ConfigSuite) TestSaveConfig(c *C) {
@@ -30,6 +31,7 @@ func (s *ConfigSuite) TestSaveConfig(c *C) {
s.config.RootDir = "/tmp/aptly"
s.config.DownloadConcurrency = 5
s.config.DatabaseOpenAttempts = 5
s.config.GpgProvider = "gpg"
s.config.FileSystemPublishRoots = map[string]FileSystemPublishRoot{"test": {
@@ -58,6 +60,7 @@ func (s *ConfigSuite) TestSaveConfig(c *C) {
" \"downloadConcurrency\": 5,\n"+
" \"downloadSpeedLimit\": 0,\n"+
" \"downloadRetries\": 0,\n"+
" \"databaseOpenAttempts\": 5,\n"+
" \"architectures\": null,\n"+
" \"dependencyFollowSuggests\": false,\n"+
" \"dependencyFollowRecommends\": false,\n"+
@@ -115,4 +118,4 @@ func (s *ConfigSuite) TestSaveConfig(c *C) {
"}")
}
const configFile = `{"rootDir": "/opt/aptly/", "downloadConcurrency": 33}`
const configFile = `{"rootDir": "/opt/aptly/", "downloadConcurrency": 33, "databaseOpenAttempts": 33}`