diff options
author | Jonas <cez81@users.noreply.github.com> | 2017-04-08 17:27:26 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-04-08 23:27:26 +0800 |
commit | 54f0293f0ab73f357f545f8e05d16f9b254aba5e (patch) | |
tree | b95f86dd93e7c74cada06a919d7f790c2ca1d083 /modules | |
parent | edbb9eefd6c12d6c67bf864539a51f5a09c7d670 (diff) | |
download | gitea-54f0293f0ab73f357f545f8e05d16f9b254aba5e.tar.gz gitea-54f0293f0ab73f357f545f8e05d16f9b254aba5e.zip |
Mirror sync interval specified as duration string (#1407)
* Sync interval specifed as duration string
* Changed mirror interval text
* make fmt
* Add MinInterval for mirror sync
* Use duration internally
* Changed min default to 10m
* make fmt
* Incorrect default
* Removed defaults in MustDuration()
* Add Mirror interval migration
* Default values corrected
* Use transaction during migration
* Change http 500 to page with error message
* Cleanup session.commit()
Diffstat (limited to 'modules')
-rw-r--r-- | modules/auth/repo_form.go | 2 | ||||
-rw-r--r-- | modules/setting/setting.go | 21 |
2 files changed, 14 insertions, 9 deletions
diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index 7fdb5e67e2..dd3fbff7bf 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -88,7 +88,7 @@ type RepoSettingForm struct { RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"` Description string `binding:"MaxSize(255)"` Website string `binding:"Url;MaxSize(255)"` - Interval int + Interval string MirrorAddress string Private bool EnablePrune bool diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 5a0666ade2..c2e08b0c14 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -417,10 +417,9 @@ var ( } // Mirror settings - Mirror = struct { - DefaultInterval int - }{ - DefaultInterval: 8, + Mirror struct { + DefaultInterval time.Duration + MinInterval time.Duration } // API settings @@ -886,14 +885,20 @@ please consider changing to GITEA_CUSTOM`) log.Fatal(4, "Failed to map Cron settings: %v", err) } else if err = Cfg.Section("git").MapTo(&Git); err != nil { log.Fatal(4, "Failed to map Git settings: %v", err) - } else if err = Cfg.Section("mirror").MapTo(&Mirror); err != nil { - log.Fatal(4, "Failed to map Mirror settings: %v", err) } else if err = Cfg.Section("api").MapTo(&API); err != nil { log.Fatal(4, "Failed to map API settings: %v", err) } - if Mirror.DefaultInterval <= 0 { - Mirror.DefaultInterval = 24 + sec = Cfg.Section("mirror") + Mirror.MinInterval = sec.Key("MIN_INTERVAL").MustDuration(10 * time.Minute) + Mirror.DefaultInterval = sec.Key("DEFAULT_INTERVAL").MustDuration(8 * time.Hour) + if Mirror.MinInterval.Minutes() < 1 { + log.Warn("Mirror.MinInterval is too low") + Mirror.MinInterval = 1 * time.Minute + } + if Mirror.DefaultInterval < Mirror.MinInterval { + log.Warn("Mirror.DefaultInterval is less than Mirror.MinInterval") + Mirror.DefaultInterval = time.Hour * 8 } Langs = Cfg.Section("i18n").Key("LANGS").Strings(",") |