Release v1.4.35 with 413 handling for both dcrypt endpoints
- Handle 413 from paste endpoint (not just upload) - Show clear German error "DLC-Datei zu groß für dcrypt.it" when both endpoints reject the file due to size - Add tests for dual-413 and upload-413+paste-500 scenarios Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
778124312c
commit
48c89713ba
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "real-debrid-downloader",
|
"name": "real-debrid-downloader",
|
||||||
"version": "1.4.34",
|
"version": "1.4.35",
|
||||||
"description": "Real-Debrid Downloader Desktop (Electron + React + TypeScript)",
|
"description": "Real-Debrid Downloader Desktop (Electron + React + TypeScript)",
|
||||||
"main": "build/main/main/main.js",
|
"main": "build/main/main/main.js",
|
||||||
"author": "Sucukdeluxe",
|
"author": "Sucukdeluxe",
|
||||||
|
|||||||
@ -190,7 +190,7 @@ async function tryDcryptUpload(fileContent: Buffer, fileName: string): Promise<s
|
|||||||
return extractLinksFromResponse(text);
|
return extractLinksFromResponse(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function tryDcryptPaste(fileContent: Buffer): Promise<string[]> {
|
async function tryDcryptPaste(fileContent: Buffer): Promise<string[] | null> {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.set("content", fileContent.toString("ascii"));
|
form.set("content", fileContent.toString("ascii"));
|
||||||
|
|
||||||
@ -198,6 +198,9 @@ async function tryDcryptPaste(fileContent: Buffer): Promise<string[]> {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
body: form
|
body: form
|
||||||
});
|
});
|
||||||
|
if (response.status === 413) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const text = await response.text();
|
const text = await response.text();
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(compactErrorText(text));
|
throw new Error(compactErrorText(text));
|
||||||
@ -214,6 +217,9 @@ async function decryptDlcViaDcrypt(filePath: string): Promise<ParsedPackageInput
|
|||||||
if (links === null) {
|
if (links === null) {
|
||||||
links = await tryDcryptPaste(fileContent);
|
links = await tryDcryptPaste(fileContent);
|
||||||
}
|
}
|
||||||
|
if (links === null) {
|
||||||
|
throw new Error("DLC-Datei zu groß für dcrypt.it");
|
||||||
|
}
|
||||||
if (links.length === 0) {
|
if (links.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -139,7 +139,31 @@ describe("container", () => {
|
|||||||
expect(fetchSpy).toHaveBeenCalledTimes(3);
|
expect(fetchSpy).toHaveBeenCalledTimes(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("throws when both dcrypt endpoints fail", async () => {
|
it("throws when both dcrypt endpoints return 413", async () => {
|
||||||
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "rd-dlc-"));
|
||||||
|
tempDirs.push(dir);
|
||||||
|
const filePath = path.join(dir, "huge.dlc");
|
||||||
|
fs.writeFileSync(filePath, Buffer.alloc(100, 1).toString("base64"));
|
||||||
|
|
||||||
|
const fetchSpy = vi.fn(async (url: string | URL | Request) => {
|
||||||
|
const urlStr = String(url);
|
||||||
|
if (urlStr.includes("service.jdownloader.org")) {
|
||||||
|
return new Response("", { status: 404 });
|
||||||
|
}
|
||||||
|
if (urlStr.includes("dcrypt.it/decrypt/upload")) {
|
||||||
|
return new Response("Request Entity Too Large", { status: 413 });
|
||||||
|
}
|
||||||
|
if (urlStr.includes("dcrypt.it/decrypt/paste")) {
|
||||||
|
return new Response("Request Entity Too Large", { status: 413 });
|
||||||
|
}
|
||||||
|
return new Response("", { status: 500 });
|
||||||
|
});
|
||||||
|
globalThis.fetch = fetchSpy as unknown as typeof fetch;
|
||||||
|
|
||||||
|
await expect(importDlcContainers([filePath])).rejects.toThrow(/zu groß für dcrypt/i);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("throws when upload returns 413 and paste returns 500", async () => {
|
||||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "rd-dlc-"));
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "rd-dlc-"));
|
||||||
tempDirs.push(dir);
|
tempDirs.push(dir);
|
||||||
const filePath = path.join(dir, "doomed.dlc");
|
const filePath = path.join(dir, "doomed.dlc");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user