From f0ce5470e5d58a118daf8dde4b35dce904892a35 Mon Sep 17 00:00:00 2001
From: Gusted <williamzijl7@hotmail.com>
Date: Wed, 15 Jun 2022 17:58:44 +0200
Subject: [PATCH] Always try to fetch repo for mirrors (#19975)

- Always give a best-effort to fetching the repositories, if even that
fails indeed give a disconnected mirror found error.
- *Partially* resolves #19928

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
---
 services/mirror/mirror.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/services/mirror/mirror.go b/services/mirror/mirror.go
index edc5a84d22..013adac0f4 100644
--- a/services/mirror/mirror.go
+++ b/services/mirror/mirror.go
@@ -63,7 +63,7 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
 		var item SyncRequest
 		var repo *repo_model.Repository
 		if m, ok := bean.(*repo_model.Mirror); ok {
-			if m.Repo == nil {
+			if m.GetRepository() == nil {
 				log.Error("Disconnected mirror found: %d", m.ID)
 				return nil
 			}
@@ -73,7 +73,7 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
 				ReferenceID: m.RepoID,
 			}
 		} else if m, ok := bean.(*repo_model.PushMirror); ok {
-			if m.Repo == nil {
+			if m.GetRepository() == nil {
 				log.Error("Disconnected push-mirror found: %d", m.ID)
 				return nil
 			}