Update from Git Manager GUI

This commit is contained in:
2026-02-25 18:51:13 +01:00
parent 7dba3a8db8
commit ff0dc70b54
6 changed files with 480 additions and 0 deletions

58
util/queue.js Normal file
View File

@@ -0,0 +1,58 @@
/**
* util/queue.js
* Verarbeitet Update-Checks als geordnete Warteschlange
* verhindert parallele API-Anfragen und Rate-Limits.
*/
export class UpdateQueue {
constructor() {
this._queue = [];
this._running = false;
this.processed = 0; // Gesamt-Jobs seit Start
this.nextRunAt = null; // Zeitstempel des nächsten geplanten Runs
}
/** Anzahl der wartenden Jobs */
get size() {
return this._queue.length;
}
/** Ist die Queue gerade aktiv? */
get isRunning() {
return this._running;
}
/**
* Fügt einen asynchronen Job zur Queue hinzu.
* @param {() => Promise<void>} job
*/
enqueue(job) {
this._queue.push(job);
this._run();
}
/** Interne Abarbeitungsschleife läuft bis Queue leer ist */
async _run() {
if (this._running) return;
this._running = true;
while (this._queue.length > 0) {
const job = this._queue.shift();
try {
await job();
} catch (e) {
console.error("[Queue] Job-Fehler:", e.message);
}
this.processed++;
// 500ms Pause zwischen Jobs
if (this._queue.length > 0) {
await new Promise((r) => setTimeout(r, 500));
}
}
this._running = false;
}
}
export default new UpdateQueue();