add --prerelease

This commit is contained in:
2024-12-15 11:18:25 +01:00
parent da94d1b0e3
commit 1237d8c71e
7 changed files with 113 additions and 44 deletions

View File

@@ -7,8 +7,8 @@ use crate::structs;
use std::path::Path;
pub async fn remote_revision() -> u16 {
match github::latest_tag(GH_IW4X_OWNER, GH_IW4X_REPO).await {
pub async fn remote_revision(prerelease: Option<bool>) -> u16 {
match github::latest_tag(GH_IW4X_OWNER, GH_IW4X_REPO, prerelease).await {
Ok(tag) => misc::rev_to_int(&tag),
Err(_) => {
crate::println_error!("Failed to get latest version for {GH_IW4X_OWNER}/{GH_IW4X_REPO}, assuming we are up to date.");
@@ -17,8 +17,8 @@ pub async fn remote_revision() -> u16 {
}
}
pub async fn update(dir: &Path, cache: &mut structs::Cache) {
let remote = remote_revision().await;
pub async fn update(dir: &Path, cache: &mut structs::Cache, prerelease: Option<bool>) {
let remote = remote_revision(prerelease).await;
let local = misc::rev_to_int(&cache.iw4x_revision);
if remote <= local && dir.join("iw4x.dll").exists() {
@@ -34,8 +34,8 @@ pub async fn update(dir: &Path, cache: &mut structs::Cache) {
);
http_async::download_file(
&format!(
"{}/download/iw4x.dll",
github::latest_release_url(GH_IW4X_OWNER, GH_IW4X_REPO)
"{}/iw4x.dll",
github::download_url(GH_IW4X_OWNER, GH_IW4X_REPO, Some(&format!("r{remote}")))
),
&dir.join("iw4x.dll"),
)