Compare commits
No commits in common. "68bfeb574f85889f86c537321c7edc44a086e371" and "8ab01f3da48131f074d04e4cbcd656748e0edd7f" have entirely different histories.
68bfeb574f
...
8ab01f3da4
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "real-debrid-downloader",
|
"name": "real-debrid-downloader",
|
||||||
"version": "1.7.125",
|
"version": "1.7.124",
|
||||||
"description": "Desktop downloader",
|
"description": "Desktop downloader",
|
||||||
"main": "build/main/main/main.js",
|
"main": "build/main/main/main.js",
|
||||||
"author": "Sucukdeluxe",
|
"author": "Sucukdeluxe",
|
||||||
|
|||||||
@ -131,9 +131,6 @@ const PREALLOC_RESUME_MISMATCH_THRESHOLD_BYTES = 1024 * 1024;
|
|||||||
|
|
||||||
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;
|
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;
|
||||||
|
|
||||||
/** Files that are legitimately tiny (< 5 KB) and should NOT be rejected as suspicious. */
|
|
||||||
const KNOWN_SMALL_FILE_RE = /\.(?:sfv|nfo|nzb|md5|sha1|sha256|crc|txt|url|lnk|srr)$/i;
|
|
||||||
|
|
||||||
function expectedMinBytes(totalBytes: number | null | undefined, strict: boolean): number {
|
function expectedMinBytes(totalBytes: number | null | undefined, strict: boolean): number {
|
||||||
if (!totalBytes || totalBytes <= 0) {
|
if (!totalBytes || totalBytes <= 0) {
|
||||||
return 10240;
|
return 10240;
|
||||||
@ -440,13 +437,6 @@ function shouldRejectSuspiciousSmallDownload(
|
|||||||
const size = Math.max(0, Math.floor(Number(fileSizeOnDisk) || 0));
|
const size = Math.max(0, Math.floor(Number(fileSizeOnDisk) || 0));
|
||||||
const expected = Number.isFinite(expectedTotal || NaN) ? Math.max(0, Math.floor(expectedTotal || 0)) : 0;
|
const expected = Number.isFinite(expectedTotal || NaN) ? Math.max(0, Math.floor(expectedTotal || 0)) : 0;
|
||||||
const binaryLike = isLargeBinaryLikePath(filePath || fileName);
|
const binaryLike = isLargeBinaryLikePath(filePath || fileName);
|
||||||
const name = path.basename(String(filePath || fileName || ""));
|
|
||||||
|
|
||||||
// Known small files (e.g. .sfv, .nfo) are legitimately tiny — never reject them
|
|
||||||
// as long as they received the expected number of bytes (or we have no expectation).
|
|
||||||
if (KNOWN_SMALL_FILE_RE.test(name) && (expected <= 0 || size >= expected)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
return expected > 0 || binaryLike;
|
return expected > 0 || binaryLike;
|
||||||
@ -9350,13 +9340,8 @@ export class DownloadManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Detect tiny error-response files (e.g. hoster returning "Forbidden" with HTTP 200).
|
// Detect tiny error-response files (e.g. hoster returning "Forbidden" with HTTP 200).
|
||||||
// No legitimate file-hoster download is < 512 bytes, EXCEPT known small metadata
|
// No legitimate file-hoster download is < 512 bytes.
|
||||||
// files like .sfv (checksum verification), .nfo (release info), etc.
|
|
||||||
if (written > 0 && written < 512) {
|
if (written > 0 && written < 512) {
|
||||||
const knownSmallFile = KNOWN_SMALL_FILE_RE.test(item.fileName || effectiveTargetPath);
|
|
||||||
if (knownSmallFile && ((!item.totalBytes || item.totalBytes <= 0) || written >= item.totalBytes)) {
|
|
||||||
logger.info(`Kleine Metadaten-Datei akzeptiert (${written} B): ${item.fileName || effectiveTargetPath}`);
|
|
||||||
} else {
|
|
||||||
let snippet = "";
|
let snippet = "";
|
||||||
try {
|
try {
|
||||||
snippet = await fs.promises.readFile(effectiveTargetPath, "utf8");
|
snippet = await fs.promises.readFile(effectiveTargetPath, "utf8");
|
||||||
@ -9383,7 +9368,6 @@ export class DownloadManager extends EventEmitter {
|
|||||||
throw new Error(`Download zu klein (${written} B) – Hoster-Fehlerseite?${snippet ? ` Inhalt: "${snippet}"` : ""}`);
|
throw new Error(`Download zu klein (${written} B) – Hoster-Fehlerseite?${snippet ? ` Inhalt: "${snippet}"` : ""}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const completionValidation = validateDownloadedFileCompletion({
|
const completionValidation = validateDownloadedFileCompletion({
|
||||||
actualBytes: written,
|
actualBytes: written,
|
||||||
|
|||||||
@ -6140,65 +6140,6 @@ describe("download manager", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("accepts small .sfv metadata files without rejecting them as suspicious", async () => {
|
|
||||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-dm-"));
|
|
||||||
tempDirs.push(root);
|
|
||||||
// SFV content is just CRC32 checksums — legitimately tiny
|
|
||||||
const sfvContent = Buffer.from("archive.part1.rar 1A2B3C4D\narchive.part2.rar 5E6F7A8B\n", "utf8");
|
|
||||||
|
|
||||||
const server = http.createServer((req, res) => {
|
|
||||||
res.statusCode = 200;
|
|
||||||
res.setHeader("Content-Length", String(sfvContent.length));
|
|
||||||
res.end(sfvContent);
|
|
||||||
});
|
|
||||||
|
|
||||||
server.listen(0, "127.0.0.1");
|
|
||||||
await once(server, "listening");
|
|
||||||
const address = server.address();
|
|
||||||
if (!address || typeof address === "string") throw new Error("server address unavailable");
|
|
||||||
const directUrl = `http://127.0.0.1:${address.port}/checksum.sfv`;
|
|
||||||
|
|
||||||
globalThis.fetch = async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
|
|
||||||
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
||||||
if (url.includes("/unrestrict/link")) {
|
|
||||||
return new Response(
|
|
||||||
JSON.stringify({ download: directUrl, filename: "archive.sfv", filesize: sfvContent.length }),
|
|
||||||
{ status: 200, headers: { "Content-Type": "application/json" } }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return originalFetch(input, init);
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const manager = new DownloadManager(
|
|
||||||
{
|
|
||||||
...defaultSettings(),
|
|
||||||
token: "rd-token",
|
|
||||||
outputDir: path.join(root, "downloads"),
|
|
||||||
extractDir: path.join(root, "extract"),
|
|
||||||
autoExtract: false,
|
|
||||||
autoReconnect: false
|
|
||||||
},
|
|
||||||
emptySession(),
|
|
||||||
createStoragePaths(path.join(root, "state"))
|
|
||||||
);
|
|
||||||
|
|
||||||
manager.addPackages([{ name: "sfv-test", links: ["https://dummy/sfv-file"] }]);
|
|
||||||
await manager.start();
|
|
||||||
await waitFor(() => !manager.getSnapshot().session.running, 15000);
|
|
||||||
|
|
||||||
const item = Object.values(manager.getSnapshot().session.items)[0];
|
|
||||||
expect(item?.status).toBe("completed");
|
|
||||||
expect(item?.retries).toBe(0);
|
|
||||||
expect(fs.existsSync(item.targetPath)).toBe(true);
|
|
||||||
const onDisk = fs.readFileSync(item.targetPath);
|
|
||||||
expect(onDisk.length).toBe(sfvContent.length);
|
|
||||||
} finally {
|
|
||||||
server.close();
|
|
||||||
await once(server, "close");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("limits AllDebrid rapidgator starts to one active task by default", async () => {
|
it("limits AllDebrid rapidgator starts to one active task by default", async () => {
|
||||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-dm-"));
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-dm-"));
|
||||||
tempDirs.push(root);
|
tempDirs.push(root);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user