Gesamtprüfung: Zeitlimit für Gitea, Aufräumen ohne Weiterleitung

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-09-30 10:21:34 +00:00
1 parent febac3c2a3
commit d5c70a5bd6
7 files changed
+233 -11

No files matched your search

+18 -4
View File
@@ -1,5 +1,8 @@
import { config } from '../config.js'
/** Zeitlimit fuer jeden Gitea-API-Aufruf, in ms (ueberschreibbar via `GITEA_TIMEOUT_MS`, s. config.js). */
const GITEA_TIMEOUT_MS = config.gitea.timeoutMs
/**
* Baut die Authorization-/Content-Type-Header fuer einen Gitea-API-Aufruf.
* Wirft, wenn GITEA_API_TOKEN nicht gesetzt ist.
@@ -18,12 +21,23 @@ function giteaHeaders() {
* Ruft `${config.gitea.baseUrl}/api/v1<path>` auf und liefert die geparste JSON-Antwort
* (oder null ohne Body). Eine Nicht-2xx-Antwort wirft eine Error mit .status; ein 409
* "same name already exists" wird in die deutsche Meldung uebersetzt (Subdomain-/Repo-Name).
* Bricht nach `GITEA_TIMEOUT_MS` ab (Standard 30 s); der Abbruch wirft eine Error OHNE .status,
* damit repoMove/projectAssignment ihn wie "Gitea nicht erreichbar" einordnen.
*/
export async function giteaFetch(path, options = {}) {
const response = await fetch(`${config.gitea.baseUrl}/api/v1${path}`, {
...options,
headers: { ...giteaHeaders(), ...options.headers },
})
let response
try {
response = await fetch(`${config.gitea.baseUrl}/api/v1${path}`, {
...options,
headers: { ...giteaHeaders(), ...options.headers },
signal: options.signal || AbortSignal.timeout(GITEA_TIMEOUT_MS),
})
} catch (err) {
if (err?.name === 'TimeoutError' || err?.name === 'AbortError') {
throw new Error(`Gitea antwortet nicht (Zeitlimit ${Math.round(GITEA_TIMEOUT_MS / 1000)} s)`)
}
throw err
}
const text = await response.text()
let data = null