From 949c1331afde312135eb272a9a4661be189c2e14 Mon Sep 17 00:00:00 2001 From: lashman Date: Sat, 21 Mar 2026 22:40:16 +0200 Subject: [PATCH] configurable auto-sync interval for gitea plugin --- plugins/gitea-sync/index.js | 21 +++++++++++++++++++++ plugins/gitea-sync/manifest.json | 16 +++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/plugins/gitea-sync/index.js b/plugins/gitea-sync/index.js index 0dcfbe9..b21776d 100644 --- a/plugins/gitea-sync/index.js +++ b/plugins/gitea-sync/index.js @@ -179,6 +179,25 @@ async function syncRepos(ctx) { return { synced: repos.length, created, updated, changelogsCreated }; } +let syncTimer = null; + +function startAutoSync(ctx) { + stopAutoSync(); + const minutes = parseInt(ctx.config.syncInterval, 10); + if (!minutes || isNaN(minutes)) return; + ctx.logger.info({ intervalMinutes: minutes }, "gitea-sync: auto-sync enabled"); + syncTimer = setInterval(() => { + syncRepos(ctx).catch((err) => ctx.logger.warn({ error: err.message }, "gitea-sync: auto-sync failed")); + }, minutes * 60 * 1000); +} + +function stopAutoSync() { + if (syncTimer) { + clearInterval(syncTimer); + syncTimer = null; + } +} + export default { routes: [ { @@ -215,9 +234,11 @@ export default { ctx.logger.warn({ error: err.message }, "gitea-sync: initial sync failed"); } } + startAutoSync(ctx); }, async onDisable(ctx) { + stopAutoSync(); ctx.logger.info("gitea-sync plugin disabled"); }, } diff --git a/plugins/gitea-sync/manifest.json b/plugins/gitea-sync/manifest.json index 0404fa8..5ce8e3a 100644 --- a/plugins/gitea-sync/manifest.json +++ b/plugins/gitea-sync/manifest.json @@ -1,6 +1,6 @@ { "name": "gitea-sync", - "version": "1.0.0", + "version": "1.1.0", "description": "Syncs public repositories from a Gitea instance as feedback boards", "author": "echoboard", "entryPoint": "index.js", @@ -17,6 +17,20 @@ "type": "password", "label": "API token", "placeholder": "Leave empty for public repos only" + }, + { + "key": "syncInterval", + "type": "select", + "label": "Auto-sync interval", + "options": [ + { "value": "off", "label": "Off - manual only" }, + { "value": "15", "label": "Every 15 minutes" }, + { "value": "30", "label": "Every 30 minutes" }, + { "value": "60", "label": "Every hour" }, + { "value": "360", "label": "Every 6 hours" }, + { "value": "720", "label": "Every 12 hours" }, + { "value": "1440", "label": "Every 24 hours" } + ] } ] }