Compare commits

...

4 Commits

Author SHA1 Message Date
Chubby Granny Chaser
fc4043c2c4 Update scripts/postinstall.cjs
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2025-04-09 08:01:03 +01:00
Chubby Granny Chaser
97cf02577a fix: removing console log 2025-04-09 08:00:15 +01:00
Chubby Granny Chaser
fbce53d61a fix: removing console log 2025-04-09 07:59:34 +01:00
Chubby Granny Chaser
1835adf8b4 fix: fixing multiple connections 2025-04-09 07:57:00 +01:00
6 changed files with 68 additions and 50 deletions

View File

@@ -1,48 +1,61 @@
import aria2p
class HttpDownloader:
def __init__(self):
self.download = None
self.aria2 = aria2p.API(
aria2p.Client(
host="http://localhost",
port=6800,
secret=""
)
)
def __init__(self):
self.download = None
self.aria2 = aria2p.API(
aria2p.Client(
host="http://localhost",
port=6800,
secret=""
)
)
def start_download(self, url: str, save_path: str, header: str, out: str = None):
if self.download:
self.aria2.resume([self.download])
else:
downloads = self.aria2.add(url, options={"header": header, "dir": save_path, "out": out})
self.download = downloads[0]
def pause_download(self):
if self.download:
self.aria2.pause([self.download])
def cancel_download(self):
if self.download:
self.aria2.remove([self.download])
self.download = None
def start_download(self, url: str, save_path: str, header: str, out: str = None, allow_multiple_connections: bool = False):
if self.download:
self.aria2.resume([self.download])
else:
options = {
"header": header,
"dir": save_path,
"out": out
}
def get_download_status(self):
if self.download == None:
return None
if allow_multiple_connections:
options.update({
"split": "16",
"max-connection-per-server": "16",
"min-split-size": "1M"
})
downloads = self.aria2.add(url, options=options)
self.download = downloads[0]
def pause_download(self):
if self.download:
self.aria2.pause([self.download])
def cancel_download(self):
if self.download:
self.aria2.remove([self.download])
self.download = None
download = self.aria2.get_download(self.download.gid)
def get_download_status(self):
if self.download == None:
return None
response = {
'folderName': download.name,
'fileSize': download.total_length,
'progress': download.completed_length / download.total_length if download.total_length else 0,
'downloadSpeed': download.download_speed,
'numPeers': 0,
'numSeeds': 0,
'status': download.status,
'bytesDownloaded': download.completed_length,
}
download = self.aria2.get_download(self.download.gid)
return response
response = {
'folderName': download.name,
'fileSize': download.total_length,
'progress': download.completed_length / download.total_length if download.total_length else 0,
'downloadSpeed': download.download_speed,
'numPeers': 0,
'numSeeds': 0,
'status': download.status,
'bytesDownloaded': download.completed_length,
}
return response

View File

@@ -147,11 +147,11 @@ def action():
torrent_downloader.start_download(url, data['save_path'])
else:
if existing_downloader and isinstance(existing_downloader, HttpDownloader):
existing_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'))
existing_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'), data.get('allow_multiple_connections', False))
else:
http_downloader = HttpDownloader()
downloads[game_id] = http_downloader
http_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'))
http_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'), data.get('allow_multiple_connections', False))
downloading_game_id = game_id

View File

@@ -123,3 +123,14 @@ const copyAria2 = () => {
copyAria2();
downloadLudusavi();
if (process.platform !== "win32") {
const binariesPath = path.join(__dirname, "..", "binaries");
if (fs.existsSync(binariesPath)) {
const zzzPath = path.join(binariesPath, "7zz");
const zzzsPath = path.join(binariesPath, "7zzs");
if (fs.existsSync(zzzPath)) fs.chmodSync(zzzPath, 0o755);
if (fs.existsSync(zzzsPath)) fs.chmodSync(zzzsPath, 0o755);
}
}

View File

@@ -50,8 +50,6 @@ export class SevenZip {
});
child.once("exit", (code) => {
console.log("EXIT CALLED", code, filePath);
if (code === 0) {
successCb();
return;

View File

@@ -16,12 +16,6 @@ export class Aria2 {
"--rpc-listen-all",
"--file-allocation=none",
"--allow-overwrite=true",
"-s",
"16",
"-x",
"16",
"-k",
"1M",
],
{ stdio: "inherit", windowsHide: true }
);

View File

@@ -371,6 +371,7 @@ export class DownloadManager {
game_id: downloadId,
url: downloadUrl,
save_path: download.downloadPath,
allow_multiple_connections: true,
};
}
case Downloader.TorBox: {
@@ -383,6 +384,7 @@ export class DownloadManager {
url,
save_path: download.downloadPath,
out: name,
allow_multiple_connections: true,
};
}
}