From ce3ed6f17ce75b42167af976e11842405c424bbb Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Mon, 23 Dec 2024 23:44:33 -0300 Subject: [PATCH 1/5] fix: seeding --- src/main/main.ts | 1 + src/main/services/download/download-manager.ts | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/main.ts b/src/main/main.ts index 5522becb2..03794ce33 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -39,6 +39,7 @@ const loadState = async (userPreferences: UserPreferences | null) => { shouldSeed: true, downloader: 1, progress: 1, + status: "seeding", }, }); diff --git a/src/main/services/download/download-manager.ts b/src/main/services/download/download-manager.ts index 29b117fdf..80a3f6fb8 100644 --- a/src/main/services/download/download-manager.ts +++ b/src/main/services/download/download-manager.ts @@ -100,8 +100,6 @@ export class DownloadManager { public static async watchDownloads() { const status = await this.getDownloadStatus(); - // status = await RealDebridDownloader.getStatus(); - if (status) { const { gameId, progress } = status; const game = await gameRepository.findOne({ From 789bccf77a90afa0eca5e35533baa0d06b7ef87f Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Mon, 23 Dec 2024 23:45:21 -0300 Subject: [PATCH 2/5] chore: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8f6612fe3..402d45cb3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hydralauncher", - "version": "3.1.0", + "version": "3.1.1", "description": "Hydra", "main": "./out/main/index.js", "author": "Los Broxas", From 60e0b39f860e7f155cb17732c2fad0d9149e01fd Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Mon, 23 Dec 2024 23:47:34 -0300 Subject: [PATCH 3/5] feat: use enum --- src/main/events/torrenting/resume-game-seed.ts | 3 ++- src/main/main.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/events/torrenting/resume-game-seed.ts b/src/main/events/torrenting/resume-game-seed.ts index 6310f5b81..9f79e53a4 100644 --- a/src/main/events/torrenting/resume-game-seed.ts +++ b/src/main/events/torrenting/resume-game-seed.ts @@ -1,6 +1,7 @@ import { registerEvent } from "../register-event"; import { gameRepository } from "../../repository"; import { DownloadManager } from "@main/services"; +import { Downloader } from "@shared"; const resumeGameSeed = async ( _event: Electron.IpcMainInvokeEvent, @@ -10,7 +11,7 @@ const resumeGameSeed = async ( where: { id: gameId, isDeleted: false, - downloader: 1, + downloader: Downloader.Torrent, progress: 1, }, }); diff --git a/src/main/main.ts b/src/main/main.ts index 03794ce33..0b472a5b1 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -9,6 +9,7 @@ import { RealDebridClient } from "./services/download/real-debrid"; import { HydraApi } from "./services/hydra-api"; import { uploadGamesBatch } from "./services/library-sync"; import { Aria2 } from "./services/aria2"; +import { Downloader } from "@shared"; const loadState = async (userPreferences: UserPreferences | null) => { import("./events"); @@ -37,7 +38,7 @@ const loadState = async (userPreferences: UserPreferences | null) => { const seedList = await gameRepository.find({ where: { shouldSeed: true, - downloader: 1, + downloader: Downloader.Torrent, progress: 1, status: "seeding", }, From 538d3e59822cdcc2a92abf7417df62b1c2efd241 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Tue, 24 Dec 2024 00:23:50 -0300 Subject: [PATCH 4/5] feat: set libtorrent flags --- python_rpc/main.py | 4 ++-- python_rpc/torrent_downloader.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python_rpc/main.py b/python_rpc/main.py index 36c0a922e..c1f410d17 100644 --- a/python_rpc/main.py +++ b/python_rpc/main.py @@ -36,7 +36,7 @@ if start_seeding_payload: initial_seeding = json.loads(urllib.parse.unquote(start_seeding_payload)) for seed in initial_seeding: - torrent_downloader = TorrentDownloader(torrent_session) + torrent_downloader = TorrentDownloader(torrent_session, lt.torrent_flags.upload_mode) downloads[seed['game_id']] = torrent_downloader torrent_downloader.start_download(seed['url'], seed['save_path'], "") @@ -156,7 +156,7 @@ def action(): if downloader: downloader.cancel_download() elif action == 'resume_seeding': - torrent_downloader = TorrentDownloader(torrent_session) + torrent_downloader = TorrentDownloader(torrent_session, lt.torrent_flags.upload_mode) downloads[game_id] = torrent_downloader torrent_downloader.start_download(data['url'], data['save_path'], "") elif action == 'pause_seeding': diff --git a/python_rpc/torrent_downloader.py b/python_rpc/torrent_downloader.py index 46ee4e332..ca4c2fa8f 100644 --- a/python_rpc/torrent_downloader.py +++ b/python_rpc/torrent_downloader.py @@ -1,9 +1,10 @@ import libtorrent as lt class TorrentDownloader: - def __init__(self, torrent_session): + def __init__(self, torrent_session, flags = lt.torrent_flags.auto_managed): self.torrent_handle = None self.session = torrent_session + self.flags = flags self.trackers = [ "udp://tracker.opentrackr.org:1337/announce", "http://tracker.opentrackr.org:1337/announce", @@ -102,9 +103,8 @@ def __init__(self, torrent_session): ] def start_download(self, magnet: str, save_path: str, header: str): - params = {'url': magnet, 'save_path': save_path, 'trackers': self.trackers} + params = {'url': magnet, 'save_path': save_path, 'trackers': self.trackers, 'flags': self.flags} self.torrent_handle = self.session.add_torrent(params) - self.torrent_handle.set_flags(lt.torrent_flags.auto_managed) self.torrent_handle.resume() def pause_download(self): From e211517e24a3ad0a78e785dc24bf8e480cf62803 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Tue, 24 Dec 2024 00:26:58 -0300 Subject: [PATCH 5/5] feat: revert change --- src/main/main.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/main.ts b/src/main/main.ts index 0b472a5b1..9e00ff6aa 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -40,7 +40,6 @@ const loadState = async (userPreferences: UserPreferences | null) => { shouldSeed: true, downloader: Downloader.Torrent, progress: 1, - status: "seeding", }, });