Skip to content

Commit

Permalink
Merge pull request #1325 from hydralauncher/fix/stop-seeding-games-th…
Browse files Browse the repository at this point in the history
…at-are-not-downloaded-on-startup

fix: seeding
  • Loading branch information
zamitto authored Dec 24, 2024
2 parents 54c6b1f + e211517 commit f8b9fe8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hydralauncher",
"version": "3.1.0",
"version": "3.1.1",
"description": "Hydra",
"main": "./out/main/index.js",
"author": "Los Broxas",
Expand Down
4 changes: 2 additions & 2 deletions python_rpc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'], "")

Expand Down Expand Up @@ -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':
Expand Down
6 changes: 3 additions & 3 deletions python_rpc/torrent_downloader.py
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion src/main/events/torrenting/resume-game-seed.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -10,7 +11,7 @@ const resumeGameSeed = async (
where: {
id: gameId,
isDeleted: false,
downloader: 1,
downloader: Downloader.Torrent,
progress: 1,
},
});
Expand Down
3 changes: 2 additions & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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,
},
});
Expand Down
2 changes: 0 additions & 2 deletions src/main/services/download/download-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit f8b9fe8

Please sign in to comment.