@@ -299,6 +299,43 @@ func SettingsPost(ctx *context.Context) {
299299 ctx .Flash .Info (ctx .Tr ("repo.settings.mirror_sync_in_progress" ))
300300 ctx .Redirect (repo .Link () + "/settings" )
301301
302+ case "push-mirror-update" :
303+ if ! setting .Mirror .Enabled {
304+ ctx .NotFound ("" , nil )
305+ return
306+ }
307+
308+ // This section doesn't require repo_name/RepoName to be set in the form, don't show it
309+ // as an error on the UI for this action
310+ ctx .Data ["Err_RepoName" ] = nil
311+
312+ interval , err := time .ParseDuration (form .PushMirrorInterval )
313+ if err != nil || (interval != 0 && interval < setting .Mirror .MinInterval ) {
314+ ctx .RenderWithErr (ctx .Tr ("repo.mirror_interval_invalid" ), tplSettingsOptions , & forms.RepoSettingForm {})
315+ return
316+ }
317+
318+ id , err := strconv .ParseInt (form .PushMirrorID , 10 , 64 )
319+ if err != nil {
320+ ctx .ServerError ("UpdatePushMirrorIntervalPushMirrorID" , err )
321+ return
322+ }
323+ m := & repo_model.PushMirror {
324+ ID : id ,
325+ Interval : interval ,
326+ }
327+ if err := repo_model .UpdatePushMirrorInterval (ctx , m ); err != nil {
328+ ctx .ServerError ("UpdatePushMirrorInterval" , err )
329+ return
330+ }
331+ // Background why we are adding it to Queue
332+ // If we observed its implementation in the context of `push-mirror-sync` where it
333+ // is evident that pushing to the queue is necessary for updates.
334+ // So, there are updates within the given interval, it is necessary to update the queue accordingly.
335+ mirror_module .AddPushMirrorToQueue (m .ID )
336+ ctx .Flash .Success (ctx .Tr ("repo.settings.update_settings_success" ))
337+ ctx .Redirect (repo .Link () + "/settings" )
338+
302339 case "push-mirror-remove" :
303340 if ! setting .Mirror .Enabled {
304341 ctx .NotFound ("" , nil )
0 commit comments