Move provider settings to tab and improve DLC filename resolution
Build and Release / build (push) Has been cancelled

This commit is contained in:
Sucukdeluxe
2026-02-27 04:40:21 +01:00
parent 02370a40b4
commit 3ef2ee732a
6 changed files with 197 additions and 38 deletions
+51
View File
@@ -165,6 +165,7 @@ export class DownloadManager extends EventEmitter {
public addPackages(packages: ParsedPackageInput[]): { addedPackages: number; addedLinks: number } {
let addedPackages = 0;
let addedLinks = 0;
const unresolvedByLink = new Map<string, string[]>();
for (const pkg of packages) {
const links = pkg.links.filter((link) => !!link.trim());
if (links.length === 0) {
@@ -211,6 +212,11 @@ export class DownloadManager extends EventEmitter {
};
packageEntry.itemIds.push(itemId);
this.session.items[itemId] = item;
if (fileName === "download.bin") {
const existing = unresolvedByLink.get(link) ?? [];
existing.push(itemId);
unresolvedByLink.set(link, existing);
}
addedLinks += 1;
}
@@ -221,9 +227,54 @@ export class DownloadManager extends EventEmitter {
this.persistSoon();
this.emitState();
if (unresolvedByLink.size > 0) {
void this.resolveQueuedFilenames(unresolvedByLink);
}
return { addedPackages, addedLinks };
}
private async resolveQueuedFilenames(unresolvedByLink: Map<string, string[]>): Promise<void> {
try {
const resolved = await this.debridService.resolveFilenames(Array.from(unresolvedByLink.keys()));
if (resolved.size === 0) {
return;
}
let changed = false;
for (const [link, itemIds] of unresolvedByLink.entries()) {
const fileName = resolved.get(link);
if (!fileName || fileName.toLowerCase() === "download.bin") {
continue;
}
const normalized = sanitizeFilename(fileName);
if (!normalized || normalized.toLowerCase() === "download.bin") {
continue;
}
for (const itemId of itemIds) {
const item = this.session.items[itemId];
if (!item) {
continue;
}
if (item.fileName !== "download.bin") {
continue;
}
item.fileName = normalized;
item.targetPath = path.join(this.session.packages[item.packageId]?.outputDir || this.settings.outputDir, normalized);
item.updatedAt = nowMs();
changed = true;
}
}
if (changed) {
this.persistSoon();
this.emitState();
}
} catch (error) {
logger.warn(`Dateinamen-Resolve fehlgeschlagen: ${compactErrorText(error)}`);
}
}
public cancelPackage(packageId: string): void {
const pkg = this.session.packages[packageId];
if (!pkg) {