diff options
author | Unknwon <u@gogs.io> | 2016-02-29 19:29:49 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-02-29 19:29:49 -0500 |
commit | 9e89584cb4aa6321311dd291c364c5d956fcead1 (patch) | |
tree | 5712509c42d1f3f55970daa9a210b19b4c8cfc95 /models | |
parent | ea80274229bca259a64fed7eca181e4a82ff0676 (diff) | |
download | gitea-9e89584cb4aa6321311dd291c364c5d956fcead1.tar.gz gitea-9e89584cb4aa6321311dd291c364c5d956fcead1.zip |
Allow setting git operations timeouts
- Migrate: #2704 #2653
- Clone: #2701
- Mirror, Pull
Diffstat (limited to 'models')
-rw-r--r-- | models/repo.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/models/repo.go b/models/repo.go index 3011253d77..cb040d5b34 100644 --- a/models/repo.go +++ b/models/repo.go @@ -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) |