0.12.0 Begin neu Architecture
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user