0.12.0 Begin neu Architecture

This commit is contained in:
2026-03-18 15:35:10 +00:00
parent d00191324b
commit 0a9cf6969f
30 changed files with 4570 additions and 183 deletions
+40 -5
View File
@@ -119,6 +119,7 @@ class DownloadService {
}
const nowIso = new Date().toISOString();
const pendingResumeIds = [];
for (const entry of entries) {
if (!entry.isFile() || !entry.name.endsWith('.json')) {
@@ -136,11 +137,34 @@ class DownloadService {
let changed = false;
if (item.status === 'queued' || item.status === 'processing') {
item.status = 'failed';
item.errorMessage = 'ZIP-Erstellung wurde durch einen Server-Neustart unterbrochen.';
item.finishedAt = nowIso;
changed = true;
await this._safeUnlink(item.partialPath);
const archiveExists = await this._pathExists(item.archivePath);
if (archiveExists) {
const archiveStat = await fs.promises.stat(item.archivePath).catch(() => null);
item.status = 'ready';
item.errorMessage = null;
item.finishedAt = item.finishedAt || nowIso;
item.sizeBytes = Number.isFinite(Number(archiveStat?.size))
? archiveStat.size
: item.sizeBytes;
changed = true;
logger.warn('download:init:recovered-ready-archive', {
id: item.id,
archiveName: item.archiveName
});
} else {
item.status = 'queued';
item.startedAt = null;
item.finishedAt = null;
item.errorMessage = null;
item.sizeBytes = null;
changed = true;
pendingResumeIds.push(item.id);
await this._safeUnlink(item.partialPath);
logger.warn('download:init:requeue-interrupted-job', {
id: item.id,
archiveName: item.archiveName
});
}
} else if (item.status === 'ready') {
const exists = await this._pathExists(item.archivePath);
if (!exists) {
@@ -157,6 +181,17 @@ class DownloadService {
await this._persistItem(item);
}
}
if (pendingResumeIds.length > 0) {
logger.warn('download:init:resume-pending-jobs', {
count: pendingResumeIds.length
});
setImmediate(() => {
for (const id of pendingResumeIds) {
void this._startArchiveJob(id);
}
});
}
}
_normalizeLoadedItem(rawItem, fallbackDir) {