Skip to content

Commit f8b9fe8

Browse files
authored
Merge pull request #1325 from hydralauncher/fix/stop-seeding-games-that-are-not-downloaded-on-startup
fix: seeding
2 parents 54c6b1f + e211517 commit f8b9fe8

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hydralauncher",
3-
"version": "3.1.0",
3+
"version": "3.1.1",
44
"description": "Hydra",
55
"main": "./out/main/index.js",
66
"author": "Los Broxas",

python_rpc/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
if start_seeding_payload:
3737
initial_seeding = json.loads(urllib.parse.unquote(start_seeding_payload))
3838
for seed in initial_seeding:
39-
torrent_downloader = TorrentDownloader(torrent_session)
39+
torrent_downloader = TorrentDownloader(torrent_session, lt.torrent_flags.upload_mode)
4040
downloads[seed['game_id']] = torrent_downloader
4141
torrent_downloader.start_download(seed['url'], seed['save_path'], "")
4242

@@ -156,7 +156,7 @@ def action():
156156
if downloader:
157157
downloader.cancel_download()
158158
elif action == 'resume_seeding':
159-
torrent_downloader = TorrentDownloader(torrent_session)
159+
torrent_downloader = TorrentDownloader(torrent_session, lt.torrent_flags.upload_mode)
160160
downloads[game_id] = torrent_downloader
161161
torrent_downloader.start_download(data['url'], data['save_path'], "")
162162
elif action == 'pause_seeding':

python_rpc/torrent_downloader.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import libtorrent as lt
22

33
class TorrentDownloader:
4-
def __init__(self, torrent_session):
4+
def __init__(self, torrent_session, flags = lt.torrent_flags.auto_managed):
55
self.torrent_handle = None
66
self.session = torrent_session
7+
self.flags = flags
78
self.trackers = [
89
"udp://tracker.opentrackr.org:1337/announce",
910
"http://tracker.opentrackr.org:1337/announce",
@@ -102,9 +103,8 @@ def __init__(self, torrent_session):
102103
]
103104

104105
def start_download(self, magnet: str, save_path: str, header: str):
105-
params = {'url': magnet, 'save_path': save_path, 'trackers': self.trackers}
106+
params = {'url': magnet, 'save_path': save_path, 'trackers': self.trackers, 'flags': self.flags}
106107
self.torrent_handle = self.session.add_torrent(params)
107-
self.torrent_handle.set_flags(lt.torrent_flags.auto_managed)
108108
self.torrent_handle.resume()
109109

110110
def pause_download(self):

src/main/events/torrenting/resume-game-seed.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { registerEvent } from "../register-event";
22
import { gameRepository } from "../../repository";
33
import { DownloadManager } from "@main/services";
4+
import { Downloader } from "@shared";
45

56
const resumeGameSeed = async (
67
_event: Electron.IpcMainInvokeEvent,
@@ -10,7 +11,7 @@ const resumeGameSeed = async (
1011
where: {
1112
id: gameId,
1213
isDeleted: false,
13-
downloader: 1,
14+
downloader: Downloader.Torrent,
1415
progress: 1,
1516
},
1617
});

src/main/main.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { RealDebridClient } from "./services/download/real-debrid";
99
import { HydraApi } from "./services/hydra-api";
1010
import { uploadGamesBatch } from "./services/library-sync";
1111
import { Aria2 } from "./services/aria2";
12+
import { Downloader } from "@shared";
1213

1314
const loadState = async (userPreferences: UserPreferences | null) => {
1415
import("./events");
@@ -37,7 +38,7 @@ const loadState = async (userPreferences: UserPreferences | null) => {
3738
const seedList = await gameRepository.find({
3839
where: {
3940
shouldSeed: true,
40-
downloader: 1,
41+
downloader: Downloader.Torrent,
4142
progress: 1,
4243
},
4344
});

src/main/services/download/download-manager.ts

-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ export class DownloadManager {
100100
public static async watchDownloads() {
101101
const status = await this.getDownloadStatus();
102102

103-
// status = await RealDebridDownloader.getStatus();
104-
105103
if (status) {
106104
const { gameId, progress } = status;
107105
const game = await gameRepository.findOne({

0 commit comments

Comments
 (0)