configurable auto-sync interval for gitea plugin

This commit is contained in:
2026-03-21 22:40:16 +02:00
parent 0558851427
commit 949c1331af
2 changed files with 36 additions and 1 deletions

View File

@@ -179,6 +179,25 @@ async function syncRepos(ctx) {
return { synced: repos.length, created, updated, changelogsCreated }; 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 { export default {
routes: [ routes: [
{ {
@@ -215,9 +234,11 @@ export default {
ctx.logger.warn({ error: err.message }, "gitea-sync: initial sync failed"); ctx.logger.warn({ error: err.message }, "gitea-sync: initial sync failed");
} }
} }
startAutoSync(ctx);
}, },
async onDisable(ctx) { async onDisable(ctx) {
stopAutoSync();
ctx.logger.info("gitea-sync plugin disabled"); ctx.logger.info("gitea-sync plugin disabled");
}, },
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "gitea-sync", "name": "gitea-sync",
"version": "1.0.0", "version": "1.1.0",
"description": "Syncs public repositories from a Gitea instance as feedback boards", "description": "Syncs public repositories from a Gitea instance as feedback boards",
"author": "echoboard", "author": "echoboard",
"entryPoint": "index.js", "entryPoint": "index.js",
@@ -17,6 +17,20 @@
"type": "password", "type": "password",
"label": "API token", "label": "API token",
"placeholder": "Leave empty for public repos only" "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" }
]
} }
] ]
} }