mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
Merge branch 'ci/rust-rpc' of github.com:hydralauncher/hydra into feat/hydra-debrid
This commit is contained in:
@@ -16,6 +16,7 @@ class HttpDownloader:
|
||||
cmd.extend([
|
||||
"--chunk-size", "10",
|
||||
"--buffer-size", "16",
|
||||
"--force-download",
|
||||
"--log",
|
||||
"--silent"
|
||||
])
|
||||
@@ -40,6 +41,7 @@ class HttpDownloader:
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"error running hydra-httpdl: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def get_download_status(self):
|
||||
|
||||
@@ -23,6 +23,7 @@ const DEFAULT_SILENT: bool = false;
|
||||
const DEFAULT_LOG: bool = false;
|
||||
const DEFAULT_FORCE_NEW: bool = false;
|
||||
const DEFAULT_RESUME_ONLY: bool = false;
|
||||
const DEFAULT_FORCE_DOWNLOAD: bool = false;
|
||||
const HEADER_SIZE: usize = 4096;
|
||||
const MAGIC_NUMBER: &[u8; 5] = b"HYDRA";
|
||||
const FORMAT_VERSION: u8 = 1;
|
||||
@@ -74,6 +75,10 @@ struct CliArgs {
|
||||
#[arg(short = 'r', long, default_value_t = DEFAULT_RESUME_ONLY)]
|
||||
resume_only: bool,
|
||||
|
||||
/// force download, ignore some verification checks
|
||||
#[arg(short = 'F', long, default_value_t = DEFAULT_FORCE_DOWNLOAD)]
|
||||
force_download: bool,
|
||||
|
||||
/// HTTP headers to send with request (format: "Key: Value")
|
||||
#[arg(short = 'H', long)]
|
||||
header: Vec<String>,
|
||||
@@ -91,6 +96,7 @@ struct DownloadConfig {
|
||||
force_new: bool,
|
||||
resume_only: bool,
|
||||
headers: Vec<String>,
|
||||
force_download: bool,
|
||||
}
|
||||
|
||||
impl DownloadConfig {
|
||||
@@ -473,6 +479,8 @@ impl Downloader {
|
||||
let pb_clone = progress.bar.clone();
|
||||
let manager_clone = Arc::clone(&resume_manager);
|
||||
let headers = self.config.headers.clone();
|
||||
let force_download = self.config.force_download;
|
||||
let should_log = self.config.should_log();
|
||||
|
||||
let chunk_size = self.config.chunk_size as u64;
|
||||
let chunk_index = (start / chunk_size) as usize;
|
||||
@@ -487,6 +495,8 @@ impl Downloader {
|
||||
pb_clone,
|
||||
DEFAULT_MAX_RETRIES,
|
||||
&headers,
|
||||
force_download,
|
||||
should_log,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -554,6 +564,8 @@ impl Downloader {
|
||||
progress_bar: Option<ProgressBar>,
|
||||
max_retries: usize,
|
||||
headers: &[String],
|
||||
force_download: bool,
|
||||
should_log: bool,
|
||||
) -> Result<()> {
|
||||
let mut retries = 0;
|
||||
loop {
|
||||
@@ -565,6 +577,8 @@ impl Downloader {
|
||||
file.clone(),
|
||||
progress_bar.clone(),
|
||||
headers,
|
||||
force_download,
|
||||
should_log,
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -591,6 +605,8 @@ impl Downloader {
|
||||
file: Arc<Mutex<BufWriter<File>>>,
|
||||
progress_bar: Option<ProgressBar>,
|
||||
headers: &[String],
|
||||
force_download: bool,
|
||||
should_log: bool,
|
||||
) -> Result<()> {
|
||||
let mut req = client
|
||||
.get(&url)
|
||||
@@ -607,7 +623,11 @@ impl Downloader {
|
||||
let resp = req.send().await?;
|
||||
|
||||
if resp.status() != StatusCode::PARTIAL_CONTENT && resp.status() != StatusCode::OK {
|
||||
anyhow::bail!("Server does not support Range requests");
|
||||
if !force_download {
|
||||
anyhow::bail!("Server does not support Range requests");
|
||||
} else if should_log {
|
||||
println!("Server does not support Range requests, ignoring...");
|
||||
}
|
||||
}
|
||||
|
||||
let mut stream = resp.bytes_stream();
|
||||
@@ -677,9 +697,13 @@ impl Downloader {
|
||||
.await?;
|
||||
|
||||
if range_check.status() != StatusCode::PARTIAL_CONTENT {
|
||||
anyhow::bail!(
|
||||
"Server does not support Range requests, cannot continue with parallel download"
|
||||
);
|
||||
if !self.config.force_download {
|
||||
anyhow::bail!(
|
||||
"Server does not support Range requests, cannot continue with parallel download"
|
||||
);
|
||||
} else if self.config.should_log() {
|
||||
println!("Server does not support Range requests, ignoring...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -909,6 +933,7 @@ async fn main() -> Result<()> {
|
||||
force_new: args.force_new,
|
||||
resume_only: args.resume_only,
|
||||
headers: args.header,
|
||||
force_download: args.force_download,
|
||||
};
|
||||
|
||||
if config.force_new && config.resume_only {
|
||||
|
||||
@@ -355,7 +355,7 @@
|
||||
"common_redist_description": "Common redistributables are required to run some games. Installing them is recommended to avoid issues.",
|
||||
"install_common_redist": "Install",
|
||||
"installing_common_redist": "Installing…",
|
||||
"show_download_speed_in_megabits": "Show download speed in megabits per second"
|
||||
"show_download_speed_in_megabytes": "Show download speed in megabytes per second"
|
||||
},
|
||||
"notifications": {
|
||||
"download_complete": "Download complete",
|
||||
|
||||
@@ -342,7 +342,7 @@
|
||||
"common_redist_description": "Componentes recomendados são necessários para executar alguns jogos. A instalação deles é recomendada para evitar problemas.",
|
||||
"install_common_redist": "Instalar",
|
||||
"installing_common_redist": "Instalando…",
|
||||
"show_download_speed_in_megabits": "Exibir taxas de download em megabits por segundo"
|
||||
"show_download_speed_in_megabytes": "Exibir taxas de download em megabytes por segundo"
|
||||
},
|
||||
"notifications": {
|
||||
"download_complete": "Download concluído",
|
||||
|
||||
@@ -102,7 +102,7 @@ export function useDownload() {
|
||||
};
|
||||
|
||||
const formatDownloadSpeed = (downloadSpeed: number): string => {
|
||||
return userPrefs?.showDownloadSpeedInMegabits
|
||||
return userPrefs?.showDownloadSpeedInMegabytes
|
||||
? `${formatBytes(downloadSpeed)}/s`
|
||||
: formatBytesToMbps(downloadSpeed);
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ export function SettingsBehavior() {
|
||||
enableAutoInstall: false,
|
||||
seedAfterDownloadComplete: false,
|
||||
showHiddenAchievementsDescription: false,
|
||||
showDownloadSpeedInMegabits: false,
|
||||
showDownloadSpeedInMegabytes: false,
|
||||
});
|
||||
|
||||
const { t } = useTranslation("settings");
|
||||
@@ -41,8 +41,8 @@ export function SettingsBehavior() {
|
||||
userPreferences.seedAfterDownloadComplete ?? false,
|
||||
showHiddenAchievementsDescription:
|
||||
userPreferences.showHiddenAchievementsDescription ?? false,
|
||||
showDownloadSpeedInMegabits:
|
||||
userPreferences.showDownloadSpeedInMegabits ?? false,
|
||||
showDownloadSpeedInMegabytes:
|
||||
userPreferences.showDownloadSpeedInMegabytes ?? false,
|
||||
});
|
||||
}
|
||||
}, [userPreferences]);
|
||||
@@ -144,11 +144,11 @@ export function SettingsBehavior() {
|
||||
/>
|
||||
|
||||
<CheckboxField
|
||||
label={t("show_download_speed_in_megabits")}
|
||||
checked={form.showDownloadSpeedInMegabits}
|
||||
label={t("show_download_speed_in_megabytes")}
|
||||
checked={form.showDownloadSpeedInMegabytes}
|
||||
onChange={() =>
|
||||
handleChange({
|
||||
showDownloadSpeedInMegabits: !form.showDownloadSpeedInMegabits,
|
||||
showDownloadSpeedInMegabytes: !form.showDownloadSpeedInMegabytes,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -85,7 +85,7 @@ export interface UserPreferences {
|
||||
repackUpdatesNotificationsEnabled?: boolean;
|
||||
achievementNotificationsEnabled?: boolean;
|
||||
friendRequestNotificationsEnabled?: boolean;
|
||||
showDownloadSpeedInMegabits?: boolean;
|
||||
showDownloadSpeedInMegabytes?: boolean;
|
||||
}
|
||||
|
||||
export interface ScreenState {
|
||||
|
||||
Reference in New Issue
Block a user