Skip to content

Commit e5e8765

Browse files
committed
fix: one single session.
1 parent 07ac201 commit e5e8765

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

models/repo_mirror.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ func MirrorUpdate() {
244244
// SyncMirrors checks and syncs mirrors.
245245
// TODO: sync more mirrors at same time.
246246
func SyncMirrors() {
247+
sess := x.NewSession()
248+
defer sess.Close()
247249
// Start listening on new sync requests.
248250
for repoID := range MirrorQueue.Queue() {
249251
log.Trace("SyncMirrors [repo_id: %v]", repoID)
@@ -260,7 +262,7 @@ func SyncMirrors() {
260262
}
261263

262264
m.ScheduleNextUpdate()
263-
if err = UpdateMirror(m); err != nil {
265+
if err = updateMirror(sess, m); err != nil {
264266
log.Error(4, "UpdateMirror [%s]: %v", repoID, err)
265267
continue
266268
}
@@ -273,7 +275,7 @@ func SyncMirrors() {
273275
continue
274276
}
275277

276-
if _, err = x.Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", commitDate.Unix(), m.RepoID); err != nil {
278+
if _, err = sess.Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", commitDate.Unix(), m.RepoID); err != nil {
277279
log.Error(2, "Update repository 'updated_unix' [%s]: %v", m.RepoID, err)
278280
continue
279281
}

0 commit comments

Comments
 (0)