@@ -10,21 +10,20 @@ import (
10
10
repo_model "code.gitea.io/gitea/models/repo"
11
11
"code.gitea.io/gitea/modules/graceful"
12
12
"code.gitea.io/gitea/modules/log"
13
- mirror_module "code.gitea.io/gitea/modules/mirror"
14
13
"code.gitea.io/gitea/modules/queue"
15
14
"code.gitea.io/gitea/modules/setting"
16
15
)
17
16
18
17
// doMirrorSync causes this request to mirror itself
19
- func doMirrorSync (ctx context.Context , req * mirror_module. SyncRequest ) {
18
+ func doMirrorSync (ctx context.Context , req * SyncRequest ) {
20
19
if req .ReferenceID == 0 {
21
20
log .Warn ("Skipping mirror sync request, no mirror ID was specified" )
22
21
return
23
22
}
24
23
switch req .Type {
25
- case mirror_module . PushMirrorType :
24
+ case PushMirrorType :
26
25
_ = SyncPushMirror (ctx , req .ReferenceID )
27
- case mirror_module . PullMirrorType :
26
+ case PullMirrorType :
28
27
_ = SyncPullMirror (ctx , req .ReferenceID )
29
28
default :
30
29
log .Error ("Unknown Request type in queue: %v for MirrorID[%d]" , req .Type , req .ReferenceID )
@@ -43,7 +42,7 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
43
42
44
43
handler := func (idx int , bean any ) error {
45
44
var repo * repo_model.Repository
46
- var mirrorType mirror_module. SyncType
45
+ var mirrorType SyncType
47
46
var referenceID int64
48
47
49
48
if m , ok := bean .(* repo_model.Mirror ); ok {
@@ -52,15 +51,15 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
52
51
return nil
53
52
}
54
53
repo = m .Repo
55
- mirrorType = mirror_module . PullMirrorType
54
+ mirrorType = PullMirrorType
56
55
referenceID = m .RepoID
57
56
} else if m , ok := bean .(* repo_model.PushMirror ); ok {
58
57
if m .GetRepository () == nil {
59
58
log .Error ("Disconnected push-mirror found: %d" , m .ID )
60
59
return nil
61
60
}
62
61
repo = m .Repo
63
- mirrorType = mirror_module . PushMirrorType
62
+ mirrorType = PushMirrorType
64
63
referenceID = m .ID
65
64
} else {
66
65
log .Error ("Unknown bean: %v" , bean )
@@ -75,9 +74,9 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
75
74
}
76
75
77
76
// Push to the Queue
78
- if err := mirror_module . PushToQueue (mirrorType , referenceID ); err != nil {
77
+ if err := PushToQueue (mirrorType , referenceID ); err != nil {
79
78
if err == queue .ErrAlreadyInQueue {
80
- if mirrorType == mirror_module . PushMirrorType {
79
+ if mirrorType == PushMirrorType {
81
80
log .Trace ("PushMirrors for %-v already queued for sync" , repo )
82
81
} else {
83
82
log .Trace ("PullMirrors for %-v already queued for sync" , repo )
@@ -120,7 +119,7 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
120
119
return nil
121
120
}
122
121
123
- func queueHandler (items ... * mirror_module. SyncRequest ) []* mirror_module. SyncRequest {
122
+ func queueHandler (items ... * SyncRequest ) []* SyncRequest {
124
123
for _ , req := range items {
125
124
doMirrorSync (graceful .GetManager ().ShutdownContext (), req )
126
125
}
@@ -129,5 +128,5 @@ func queueHandler(items ...*mirror_module.SyncRequest) []*mirror_module.SyncRequ
129
128
130
129
// InitSyncMirrors initializes a go routine to sync the mirrors
131
130
func InitSyncMirrors () {
132
- mirror_module . StartSyncMirrors (queueHandler )
131
+ StartSyncMirrors (queueHandler )
133
132
}
0 commit comments