Browse Source

mirror: update repository updated_unix after sync (#2807)

pull/4264/head
Unknwon 8 years ago
parent
commit
295d251232
No known key found for this signature in database
GPG Key ID: 7A02C406FAC875A2
  1. 2
      gogs.go
  2. 27
      models/mirror.go
  3. 2
      modules/httplib/httplib.go
  4. 2
      templates/.VERSION

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.10.8.0308" const APP_VER = "0.10.9.0308"
func init() { func init() {
setting.AppVer = APP_VER setting.AppVer = APP_VER

27
models/mirror.go

@ -76,7 +76,7 @@ func (m *Mirror) readAddress() {
cfg, err := ini.Load(m.Repo.GitConfigPath()) cfg, err := ini.Load(m.Repo.GitConfigPath())
if err != nil { if err != nil {
log.Error(4, "Load: %v", err) log.Error(2, "Load: %v", err)
return return
} }
m.address = cfg.Section("remote \"origin\"").Key("url").Value() m.address = cfg.Section("remote \"origin\"").Key("url").Value()
@ -142,9 +142,9 @@ func (m *Mirror) runSync() bool {
URL: m.FullAddress(), URL: m.FullAddress(),
Timeout: 10 * time.Second, Timeout: 10 * time.Second,
}) { }) {
desc := fmt.Sprintf("Mirror repository URL is not accessible: %s", m.MosaicsAddress()) desc := fmt.Sprintf("Source URL of mirror repository '%s' is not accessible: %s", m.Repo.FullName(), m.MosaicsAddress())
if err := CreateRepositoryNotice(desc); err != nil { if err := CreateRepositoryNotice(desc); err != nil {
log.Error(4, "CreateRepositoryNotice: %v", err) log.Error(2, "CreateRepositoryNotice: %v", err)
} }
return false return false
} }
@ -157,9 +157,9 @@ func (m *Mirror) runSync() bool {
timeout, repoPath, fmt.Sprintf("Mirror.runSync: %s", repoPath), timeout, repoPath, fmt.Sprintf("Mirror.runSync: %s", repoPath),
"git", gitArgs...); err != nil { "git", gitArgs...); err != nil {
desc := fmt.Sprintf("Fail to update mirror repository '%s': %s", repoPath, stderr) desc := fmt.Sprintf("Fail to update mirror repository '%s': %s", repoPath, stderr)
log.Error(4, desc) log.Error(2, desc)
if err = CreateRepositoryNotice(desc); err != nil { if err = CreateRepositoryNotice(desc); err != nil {
log.Error(4, "CreateRepositoryNotice: %v", err) log.Error(2, "CreateRepositoryNotice: %v", err)
} }
return false return false
} }
@ -168,9 +168,9 @@ func (m *Mirror) runSync() bool {
timeout, wikiPath, fmt.Sprintf("Mirror.runSync: %s", wikiPath), timeout, wikiPath, fmt.Sprintf("Mirror.runSync: %s", wikiPath),
"git", "remote", "update", "--prune"); err != nil { "git", "remote", "update", "--prune"); err != nil {
desc := fmt.Sprintf("Fail to update mirror wiki repository '%s': %s", wikiPath, stderr) desc := fmt.Sprintf("Fail to update mirror wiki repository '%s': %s", wikiPath, stderr)
log.Error(4, desc) log.Error(2, desc)
if err = CreateRepositoryNotice(desc); err != nil { if err = CreateRepositoryNotice(desc); err != nil {
log.Error(4, "CreateRepositoryNotice: %v", err) log.Error(2, "CreateRepositoryNotice: %v", err)
} }
return false return false
} }
@ -222,14 +222,14 @@ func MirrorUpdate() {
if err := x.Where("next_update_unix<=?", time.Now().Unix()).Iterate(new(Mirror), func(idx int, bean interface{}) error { if err := x.Where("next_update_unix<=?", time.Now().Unix()).Iterate(new(Mirror), func(idx int, bean interface{}) error {
m := bean.(*Mirror) m := bean.(*Mirror)
if m.Repo == nil { if m.Repo == nil {
log.Error(4, "Disconnected mirror repository found: %d", m.ID) log.Error(2, "Disconnected mirror repository found: %d", m.ID)
return nil return nil
} }
MirrorQueue.Add(m.RepoID) MirrorQueue.Add(m.RepoID)
return nil return nil
}); err != nil { }); err != nil {
log.Error(4, "MirrorUpdate: %v", err) log.Error(2, "MirrorUpdate: %v", err)
} }
} }
@ -243,7 +243,7 @@ func SyncMirrors() {
m, err := GetMirrorByRepoID(com.StrTo(repoID).MustInt64()) m, err := GetMirrorByRepoID(com.StrTo(repoID).MustInt64())
if err != nil { if err != nil {
log.Error(4, "GetMirrorByRepoID [%s]: %v", repoID, err) log.Error(2, "GetMirrorByRepoID [%s]: %v", m.RepoID, err)
continue continue
} }
@ -253,9 +253,14 @@ func SyncMirrors() {
m.ScheduleNextUpdate() m.ScheduleNextUpdate()
if err = UpdateMirror(m); err != nil { if err = UpdateMirror(m); err != nil {
log.Error(4, "UpdateMirror [%s]: %v", repoID, err) log.Error(2, "UpdateMirror [%s]: %v", m.RepoID, err)
continue continue
} }
// Update repository last updated time
if _, err = x.Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", time.Now().Unix(), m.RepoID); err != nil {
log.Error(2, "Update repository 'updated_unix' [%s]: %v", m.RepoID, err)
}
} }
} }

2
modules/httplib/httplib.go

@ -139,7 +139,7 @@ func (r *Request) Debug(isdebug bool) *Request {
return r return r
} }
// SetTimeout sets connect time out and read-write time out for BeegoRequest. // SetTimeout sets connect time out and read-write time out for Request.
func (r *Request) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *Request { func (r *Request) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *Request {
r.setting.ConnectTimeout = connectTimeout r.setting.ConnectTimeout = connectTimeout
r.setting.ReadWriteTimeout = readWriteTimeout r.setting.ReadWriteTimeout = readWriteTimeout

2
templates/.VERSION

@ -1 +1 @@
0.10.8.0308 0.10.9.0308
Loading…
Cancel
Save