]> source.dussan.org Git - gitea.git/commitdiff
fix #706 and other mirror improve
authorUnknwon <joe2010xtmf@163.com>
Fri, 5 Dec 2014 04:07:51 +0000 (23:07 -0500)
committerUnknwon <joe2010xtmf@163.com>
Fri, 5 Dec 2014 04:07:51 +0000 (23:07 -0500)
README.md
README_ZH.md
models/repo.go

index 0501d7efba312f9f307af059da3b0b2e04051309..716be12a07d4f86b62fffb668a70c92c81ea524e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -26,6 +26,7 @@ The goal of this project is to make the easiest, fastest and most painless way t
 - See [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team.
 - Try it before anything? Do it [online](https://try.gogs.io/Unknown/gogs) or go down to **Installation -> Install from binary** section!
 - Having troubles? Get help from [Troubleshooting](http://gogs.io/docs/intro/troubleshooting.md).
+- Want to help on localization? Check out [Crowdin](https://crowdin.com/project/gogs)!
 
 ## Features
 
index 6facfeb802f7f4f066925cfda7bf5168f68d8f04..c9982c962353db4ef2d76d628f94d4a9ce528915 100644 (file)
@@ -17,6 +17,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自
 - 您可以到 [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) 跟随开发团队的脚步。
 - 想要先睹为快?通过 [在线体验](https://try.gogs.io/Unknown/gogs) 或查看 **安装部署 -> 二进制安装** 小节。
 - 使用过程中遇到问题?尝试从 [故障排查](http://gogs.io/docs/intro/troubleshooting.md) 页面获取帮助。
+- 希望帮助多国语言界面的翻译吗?请立即访问 [Crowdin](https://crowdin.com/project/gogs)!
 
 ## 功能特性
 
index 5676a443ff84709a0136e2ff89a144fe5df47071..f2f810eb7e3d9b5c930b5df194bc612cea4374b0 100644 (file)
@@ -308,28 +308,6 @@ func MirrorRepository(repoId int64, userName, repoName, repoPath, url string) er
        return nil
 }
 
-// MirrorUpdate checks and updates mirror repositories.
-func MirrorUpdate() {
-       if err := x.Iterate(new(Mirror), func(idx int, bean interface{}) error {
-               m := bean.(*Mirror)
-               if m.NextUpdate.After(time.Now()) {
-                       return nil
-               }
-
-               repoPath := filepath.Join(setting.RepoRootPath, m.RepoName+".git")
-               if _, stderr, err := process.ExecDir(10*time.Minute,
-                       repoPath, fmt.Sprintf("MirrorUpdate: %s", repoPath),
-                       "git", "remote", "update"); err != nil {
-                       return errors.New("git remote update: " + stderr)
-               }
-
-               m.NextUpdate = time.Now().Add(time.Duration(m.Interval) * time.Hour)
-               return UpdateMirror(m)
-       }); err != nil {
-               log.Error(4, "repo.MirrorUpdate: %v", err)
-       }
-}
-
 // MigrateRepository migrates a existing repository from other project hosting.
 func MigrateRepository(u *User, name, desc string, private, mirror bool, url string) (*Repository, error) {
        repo, err := CreateRepository(u, name, desc, "", "", private, mirror, false)
@@ -1173,8 +1151,48 @@ func DeleteRepositoryArchives() error {
                })
 }
 
+var (
+       // Prevent duplicate tasks.
+       isMirrorUpdating = false
+       isGitFscking     = false
+)
+
+// MirrorUpdate checks and updates mirror repositories.
+func MirrorUpdate() {
+       if isMirrorUpdating {
+               return
+       }
+       isMirrorUpdating = true
+       defer func() { isMirrorUpdating = false }()
+
+       if err := x.Iterate(new(Mirror), func(idx int, bean interface{}) error {
+               m := bean.(*Mirror)
+               if m.NextUpdate.After(time.Now()) {
+                       return nil
+               }
+
+               repoPath := filepath.Join(setting.RepoRootPath, m.RepoName+".git")
+               if _, stderr, err := process.ExecDir(10*time.Minute,
+                       repoPath, fmt.Sprintf("MirrorUpdate: %s", repoPath),
+                       "git", "remote", "update"); err != nil {
+                       return errors.New("git remote update: " + stderr)
+               }
+
+               m.NextUpdate = time.Now().Add(time.Duration(m.Interval) * time.Hour)
+               return UpdateMirror(m)
+       }); err != nil {
+               log.Error(4, "repo.MirrorUpdate: %v", err)
+       }
+}
+
 // GitFsck calls 'git fsck' to check repository health.
 func GitFsck() {
+       if isGitFscking {
+               return
+       }
+       isGitFscking = true
+       defer func() { isGitFscking = false }()
+
        args := append([]string{"fsck"}, setting.GitFsckArgs...)
        if err := x.Where("id > 0").Iterate(new(Repository),
                func(idx int, bean interface{}) error {