Allow setting git operations timeouts
- Migrate: #2704 #2653 - Clone: #2701 - Mirror, Pull
This commit is contained in:
parent
ea80274229
commit
9e89584cb4
|
@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
|
|||
|
||||
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
||||
|
||||
##### Current version: 0.8.48
|
||||
##### Current version: 0.8.49
|
||||
|
||||
| Web | UI | Preview |
|
||||
|:-------------:|:-------:|:-------:|
|
||||
|
|
|
@ -88,7 +88,7 @@ func checkVersion() {
|
|||
{"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"},
|
||||
{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
|
||||
{"gopkg.in/macaron.v1", macaron.Version, "0.8.0"},
|
||||
{"github.com/gogits/git-module", git.Version, "0.2.7"},
|
||||
{"github.com/gogits/git-module", git.Version, "0.2.8"},
|
||||
{"github.com/gogits/go-gogs-client", gogs.Version, "0.7.3"},
|
||||
}
|
||||
for _, c := range checkers {
|
||||
|
|
|
@ -331,6 +331,13 @@ MAX_GIT_DIFF_LINES = 10000
|
|||
; see more on http://git-scm.com/docs/git-gc/1.7.5
|
||||
GC_ARGS =
|
||||
|
||||
; Operation timeout in seconds
|
||||
[git.timeout]
|
||||
MIGRATE = 600
|
||||
MIRROR = 300
|
||||
CLONE = 300
|
||||
PULL = 300
|
||||
|
||||
[i18n]
|
||||
LANGS = en-US,zh-CN,zh-HK,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT
|
||||
NAMES = English,简体中文,繁體中文,Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano
|
||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.8.48.0229"
|
||||
const APP_VER = "0.8.49.0229"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
|
|
@ -367,11 +367,16 @@ func (repo *Repository) LocalCopyPath() string {
|
|||
|
||||
func updateLocalCopy(repoPath, localPath string) error {
|
||||
if !com.IsExist(localPath) {
|
||||
if err := git.Clone(repoPath, localPath, git.CloneRepoOptions{}); err != nil {
|
||||
if err := git.Clone(repoPath, localPath, git.CloneRepoOptions{
|
||||
Timeout: time.Duration(setting.Git.Timeout.Clone) * time.Second,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("Clone: %v", err)
|
||||
}
|
||||
} else {
|
||||
if err := git.Pull(localPath, true); err != nil {
|
||||
if err := git.Pull(localPath, git.PullRemoteOptions{
|
||||
All: true,
|
||||
Timeout: time.Duration(setting.Git.Timeout.Pull) * time.Second,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("Pull: %v", err)
|
||||
}
|
||||
}
|
||||
|
@ -652,7 +657,7 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
|
|||
if err = git.Clone(opts.RemoteAddr, repoPath, git.CloneRepoOptions{
|
||||
Mirror: true,
|
||||
Quiet: true,
|
||||
Timeout: 10 * time.Minute,
|
||||
Timeout: time.Duration(setting.Git.Timeout.Migrate) * time.Second,
|
||||
}); err != nil {
|
||||
return repo, fmt.Errorf("Clone: %v", err)
|
||||
}
|
||||
|
@ -1610,7 +1615,8 @@ func MirrorUpdate() {
|
|||
}
|
||||
|
||||
repoPath := m.Repo.RepoPath()
|
||||
if _, stderr, err := process.ExecDir(10*time.Minute,
|
||||
if _, stderr, err := process.ExecDir(
|
||||
time.Duration(setting.Git.Timeout.Mirror)*time.Second,
|
||||
repoPath, fmt.Sprintf("MirrorUpdate: %s", repoPath),
|
||||
"git", "remote", "update", "--prune"); err != nil {
|
||||
desc := fmt.Sprintf("Fail to update mirror repository(%s): %s", repoPath, stderr)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -163,6 +163,12 @@ var (
|
|||
Git struct {
|
||||
MaxGitDiffLines int
|
||||
GcArgs []string `delim:" "`
|
||||
Timeout struct {
|
||||
Migrate int
|
||||
Mirror int
|
||||
Clone int
|
||||
Pull int
|
||||
} `ini:"git.timeout"`
|
||||
}
|
||||
|
||||
// Cron tasks
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.8.48.0229
|
||||
0.8.49.0229
|
Loading…
Reference in New Issue
Block a user