Release v1.7.43
This commit is contained in:
@@ -108,6 +108,8 @@ const ARCHIVE_SETTLE_POLL_MS = 250;
|
||||
|
||||
const ARCHIVE_SETTLE_MAX_WAIT_MS = 5000;
|
||||
|
||||
const MAX_SAME_DIRECT_URL_ATTEMPTS = 3;
|
||||
|
||||
const LARGE_BINARY_FILE_RE = /\.(?:part\d+\.rar|rar|r\d{2,3}|zip(?:\.\d+)?|7z(?:\.\d+)?|tar|gz|bz2|xz|iso|mkv|mp4|avi|mov|wmv|m4v|ts|m2ts|webm|mp3|flac|aac|wav)$/i;
|
||||
|
||||
function itemExpectedMinBytes(item: DownloadItem): number {
|
||||
@@ -6422,6 +6424,27 @@ export class DownloadManager extends EventEmitter {
|
||||
error: errorText,
|
||||
abortReason: reason || "none"
|
||||
});
|
||||
const directLinkRetryMatch = errorText.match(/^direct_link_retry_exhausted:(.+)$/);
|
||||
if (directLinkRetryMatch && active.genericErrorRetries < maxGenericErrorRetries) {
|
||||
active.genericErrorRetries += 1;
|
||||
item.retries += 1;
|
||||
const exhaustedReason = compactErrorText(directLinkRetryMatch[1] || errorText);
|
||||
const refreshDelayMs = retryDelayWithJitter(active.genericErrorRetries, 200);
|
||||
logger.warn(
|
||||
`Direktlink erschöpft: item=${item.fileName || item.id}, ` +
|
||||
`retry=${active.genericErrorRetries}/${retryDisplayLimit}, error=${exhaustedReason}, provider=${item.provider || "?"}`
|
||||
);
|
||||
this.queueRetry(
|
||||
item,
|
||||
active,
|
||||
refreshDelayMs,
|
||||
`Direktlink erneuern, Retry ${active.genericErrorRetries}/${retryDisplayLimit}`
|
||||
);
|
||||
item.lastError = exhaustedReason;
|
||||
this.persistSoon();
|
||||
this.emitState();
|
||||
return;
|
||||
}
|
||||
const shouldFreshRetry = !active.freshRetryUsed && isFetchFailure(errorText);
|
||||
const isHttp416 = /(^|\D)416(\D|$)/.test(errorText);
|
||||
if (isHttp416) {
|
||||
@@ -6623,7 +6646,8 @@ export class DownloadManager extends EventEmitter {
|
||||
|
||||
const configuredRetryLimit = normalizeRetryLimit(this.settings.retryLimit);
|
||||
const retryDisplayLimit = retryLimitLabel(configuredRetryLimit);
|
||||
const maxAttempts = configuredRetryLimit <= 0 ? Number.MAX_SAFE_INTEGER : configuredRetryLimit + 1;
|
||||
const maxAttemptsBySetting = configuredRetryLimit <= 0 ? Number.MAX_SAFE_INTEGER : configuredRetryLimit + 1;
|
||||
const maxAttempts = Math.max(1, Math.min(MAX_SAME_DIRECT_URL_ATTEMPTS, maxAttemptsBySetting));
|
||||
|
||||
let lastError = "";
|
||||
let effectiveTargetPath = targetPath;
|
||||
@@ -7414,15 +7438,21 @@ export class DownloadManager extends EventEmitter {
|
||||
});
|
||||
if (attempt < maxAttempts) {
|
||||
item.retries += 1;
|
||||
item.fullStatus = `Downloadfehler, retry ${attempt}/${retryDisplayLimit}`;
|
||||
item.fullStatus = `Downloadfehler, retry ${attempt}/${maxAttempts} (Direktlink)`;
|
||||
this.emitState();
|
||||
await sleep(retryDelayWithJitter(attempt, 250));
|
||||
continue;
|
||||
}
|
||||
if (maxAttemptsBySetting > maxAttempts) {
|
||||
throw new Error(`direct_link_retry_exhausted:${lastError || "Download fehlgeschlagen"}`);
|
||||
}
|
||||
throw new Error(lastError || "Download fehlgeschlagen");
|
||||
}
|
||||
}
|
||||
|
||||
if (maxAttemptsBySetting > maxAttempts) {
|
||||
throw new Error(`direct_link_retry_exhausted:${lastError || "Download fehlgeschlagen"}`);
|
||||
}
|
||||
throw new Error(lastError || "Download fehlgeschlagen");
|
||||
}
|
||||
|
||||
|
||||
+49
-14
@@ -299,8 +299,36 @@ function archiveNameKey(fileName: string): string {
|
||||
return process.platform === "win32" ? String(fileName || "").toLowerCase() : String(fileName || "");
|
||||
}
|
||||
|
||||
function stripDuplicateSuffixBeforeExtension(fileName: string): string {
|
||||
return String(fileName || "").replace(/ \(\d+\)(?=\.[^.]+$)/, "");
|
||||
}
|
||||
|
||||
function hasDuplicateSuffixBeforeExtension(fileName: string): boolean {
|
||||
return stripDuplicateSuffixBeforeExtension(fileName) !== String(fileName || "");
|
||||
}
|
||||
|
||||
function archiveDetectionName(fileName: string): string {
|
||||
return stripDuplicateSuffixBeforeExtension(path.basename(String(fileName || "")));
|
||||
}
|
||||
|
||||
function archiveCandidateIdentity(filePath: string): string {
|
||||
const normalizedPath = path.join(path.dirname(filePath), archiveDetectionName(filePath));
|
||||
return pathSetKey(normalizedPath);
|
||||
}
|
||||
|
||||
function prefersArchiveCandidate(nextCandidate: string, currentCandidate: string): boolean {
|
||||
const nextName = path.basename(nextCandidate);
|
||||
const currentName = path.basename(currentCandidate);
|
||||
const nextHasDuplicateSuffix = hasDuplicateSuffixBeforeExtension(nextName);
|
||||
const currentHasDuplicateSuffix = hasDuplicateSuffixBeforeExtension(currentName);
|
||||
if (nextHasDuplicateSuffix !== currentHasDuplicateSuffix) {
|
||||
return !nextHasDuplicateSuffix;
|
||||
}
|
||||
return ARCHIVE_SORT_COLLATOR.compare(nextName, currentName) < 0;
|
||||
}
|
||||
|
||||
function archiveSortKey(filePath: string): string {
|
||||
const fileName = path.basename(filePath).toLowerCase();
|
||||
const fileName = archiveDetectionName(filePath).toLowerCase();
|
||||
return fileName
|
||||
.replace(/\.part0*1\.rar$/i, "")
|
||||
.replace(/\.zip\.\d{3}$/i, "")
|
||||
@@ -314,7 +342,7 @@ function archiveSortKey(filePath: string): string {
|
||||
}
|
||||
|
||||
function archiveTypeRank(filePath: string): number {
|
||||
const fileName = path.basename(filePath).toLowerCase();
|
||||
const fileName = archiveDetectionName(filePath).toLowerCase();
|
||||
if (/\.part0*1\.rar$/i.test(fileName)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -359,20 +387,23 @@ export async function findArchiveCandidates(packageDir: string): Promise<string[
|
||||
return [];
|
||||
}
|
||||
|
||||
const fileNamesLower = new Set(files.map((filePath) => path.basename(filePath).toLowerCase()));
|
||||
const multipartRar = files.filter((filePath) => /\.part0*1\.rar$/i.test(filePath));
|
||||
const singleRar = files.filter((filePath) => /\.rar$/i.test(filePath) && !/\.part\d+\.rar$/i.test(filePath));
|
||||
const zipSplit = files.filter((filePath) => /\.zip\.001$/i.test(filePath));
|
||||
const fileNamesLower = new Set(files.map((filePath) => archiveDetectionName(filePath).toLowerCase()));
|
||||
const multipartRar = files.filter((filePath) => /\.part0*1\.rar$/i.test(archiveDetectionName(filePath)));
|
||||
const singleRar = files.filter((filePath) => {
|
||||
const fileName = archiveDetectionName(filePath);
|
||||
return /\.rar$/i.test(fileName) && !/\.part\d+\.rar$/i.test(fileName);
|
||||
});
|
||||
const zipSplit = files.filter((filePath) => /\.zip\.001$/i.test(archiveDetectionName(filePath)));
|
||||
const zip = files.filter((filePath) => {
|
||||
const fileName = path.basename(filePath);
|
||||
const fileName = archiveDetectionName(filePath);
|
||||
if (!/\.zip$/i.test(fileName)) {
|
||||
return false;
|
||||
}
|
||||
return !fileNamesLower.has(`${fileName}.001`.toLowerCase());
|
||||
});
|
||||
const sevenSplit = files.filter((filePath) => /\.7z\.001$/i.test(filePath));
|
||||
const sevenSplit = files.filter((filePath) => /\.7z\.001$/i.test(archiveDetectionName(filePath)));
|
||||
const seven = files.filter((filePath) => {
|
||||
const fileName = path.basename(filePath);
|
||||
const fileName = archiveDetectionName(filePath);
|
||||
if (!/\.7z$/i.test(fileName)) {
|
||||
return false;
|
||||
}
|
||||
@@ -381,20 +412,24 @@ export async function findArchiveCandidates(packageDir: string): Promise<string[
|
||||
const tarCompressed = files.filter((filePath) => /\.(?:tar\.(?:gz|bz2|xz)|tgz|tbz2|txz)$/i.test(filePath));
|
||||
// Generic .001 splits (HJSplit etc.) — exclude already-recognized .zip.001 and .7z.001
|
||||
const genericSplit = files.filter((filePath) => {
|
||||
const fileName = path.basename(filePath).toLowerCase();
|
||||
const fileName = archiveDetectionName(filePath).toLowerCase();
|
||||
if (!/\.001$/.test(fileName)) return false;
|
||||
if (/\.zip\.001$/.test(fileName) || /\.7z\.001$/.test(fileName)) return false;
|
||||
return true;
|
||||
});
|
||||
|
||||
const unique: string[] = [];
|
||||
const seen = new Set<string>();
|
||||
const seen = new Map<string, number>();
|
||||
for (const candidate of [...multipartRar, ...singleRar, ...zipSplit, ...zip, ...sevenSplit, ...seven, ...tarCompressed, ...genericSplit]) {
|
||||
const key = pathSetKey(candidate);
|
||||
if (seen.has(key)) {
|
||||
const key = archiveCandidateIdentity(candidate);
|
||||
const existingIndex = seen.get(key);
|
||||
if (existingIndex !== undefined) {
|
||||
if (prefersArchiveCandidate(candidate, unique[existingIndex])) {
|
||||
unique[existingIndex] = candidate;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
seen.add(key);
|
||||
seen.set(key, unique.length);
|
||||
unique.push(candidate);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user