chore: adding download sorting

This commit is contained in:
Chubby Granny Chaser
2025-02-01 23:52:12 +00:00
parent 7fed104afd
commit 7e54a6d0a9
15 changed files with 141 additions and 66 deletions

View File

@@ -1,4 +1,4 @@
import { Downloader } from "@shared";
import { Downloader, DownloadError } from "@shared";
import { WindowManager } from "../window-manager";
import { publishDownloadCompleteNotification } from "../notifications";
import type { Download, DownloadProgress, UserPreferences } from "@types";
@@ -263,6 +263,8 @@ export class DownloadManager {
const token = await GofileApi.authorize();
const downloadLink = await GofileApi.getDownloadLink(id!);
await GofileApi.checkDownloadUrl(downloadLink);
return {
action: "start",
game_id: downloadId,
@@ -318,10 +320,7 @@ export class DownloadManager {
case Downloader.RealDebrid: {
const downloadUrl = await RealDebridClient.getDownloadUrl(download.uri);
if (!downloadUrl)
throw new Error(
"This download is not available on Real-Debrid and polling download status from Real-Debrid is not yet available."
);
if (!downloadUrl) throw new Error(DownloadError.NotCachedInRealDebrid);
return {
action: "start",

View File

@@ -60,4 +60,12 @@ export class GofileApi {
throw new Error("Failed to get download link");
}
public static async checkDownloadUrl(url: string) {
return axios.head(url, {
headers: {
Cookie: `accountToken=${this.token}`,
},
});
}
}