Release v1.6.2

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sucukdeluxe
2026-03-04 05:41:40 +01:00
co-authored by Claude Opus 4.6
parent 17844d4c28
commit 1d4a13466f
4 changed files with 31 additions and 13 deletions
+14 -3
View File
@@ -242,7 +242,10 @@ function isUnrestrictFailure(errorText: string): boolean {
const text = String(errorText || "").toLowerCase();
return text.includes("unrestrict") || text.includes("mega-web") || text.includes("mega-debrid")
|| text.includes("bestdebrid") || text.includes("alldebrid") || text.includes("kein debrid")
|| text.includes("session") || text.includes("login");
|| text.includes("session-cookie") || text.includes("session cookie") || text.includes("session blockiert")
|| text.includes("session expired") || text.includes("invalid session")
|| text.includes("login ungültig") || text.includes("login liefert")
|| text.includes("login required") || text.includes("login failed");
}
function isProviderBusyUnrestrictError(errorText: string): boolean {
@@ -4864,6 +4867,8 @@ export class DownloadManager extends EventEmitter {
}
const acceptRanges = (response.headers.get("accept-ranges") || "").toLowerCase().includes("bytes");
let preAllocated = false;
let written = 0;
try {
if (existingBytes === 0) {
const rawHeaderName = parseContentDispositionFilename(response.headers.get("content-disposition")).trim();
@@ -4919,7 +4924,6 @@ export class DownloadManager extends EventEmitter {
await fs.promises.mkdir(path.dirname(effectiveTargetPath), { recursive: true });
// Sparse file pre-allocation (Windows only, new files with known size)
let preAllocated = false;
if (writeMode === "w" && item.totalBytes && item.totalBytes > 0 && process.platform === "win32") {
try {
const fd = await fs.promises.open(effectiveTargetPath, "w");
@@ -4934,7 +4938,7 @@ export class DownloadManager extends EventEmitter {
start: preAllocated ? 0 : undefined,
highWaterMark: STREAM_HIGH_WATER_MARK
});
let written = writeMode === "a" ? existingBytes : 0;
written = writeMode === "a" ? existingBytes : 0;
let windowBytes = 0;
let windowStarted = nowMs();
const itemCount = this.itemCount;
@@ -5313,6 +5317,13 @@ export class DownloadManager extends EventEmitter {
this.emitState();
return { resumable };
} catch (error) {
// Truncate pre-allocated sparse file to actual written bytes so that
// stat.size on the next retry reflects real data, not the pre-allocated size.
// Without this, the retry reads stat.size = totalBytes and either sends an
// impossible Range header (→ 416 → false complete) or appends to a zero-padded file.
if (preAllocated && item.totalBytes && written < item.totalBytes) {
try { await fs.promises.truncate(effectiveTargetPath, written); } catch { /* best-effort */ }
}
if (active.abortController.signal.aborted || String(error).includes("aborted:")) {
throw error;
}
-1
View File
@@ -522,7 +522,6 @@ function winRarCandidates(): string[] {
const installed = [
path.join(programFiles, "WinRAR", "UnRAR.exe"),
path.join(programFilesX86, "WinRAR", "UnRAR.exe"),
path.join(programFilesX86, "WinRAR", "UnRAR.exe")
];