Skip to content

Commit

Permalink
Merge pull request #21 from yrenum/main
Browse files Browse the repository at this point in the history
Added -allow-release-candidates option
  • Loading branch information
aintDatCap authored Jan 21, 2023
2 parents 494001a + 143640a commit d25160a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 8 additions & 4 deletions SOEdownload_manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ struct Args {
update_game: bool,
#[arg(long, action)]
update_launcher: bool,
//"https://api.github.com/repos/symphony-of-empires/symphony-of-empires/releases"
#[arg(default_value_t = String::from("https://api.github.com/repos/yrenum/symphony-of-empires/releases"))]

#[arg(long, action)]
allow_release_candidates:bool,

//"https://api.github.com/repos/yrenum/symphony-of-empires/releases"
#[arg(default_value_t = String::from("https://api.github.com/repos/symphony-of-empires/symphony-of-empires/releases"))]
game_releases_url: String,

#[arg(default_value_t = String::from("https://api.github.com/repos/symphony-of-empires/SOEutil/releases"))]
Expand All @@ -37,7 +41,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
info!("Starting game update...");

let releases = fetch_releases(&args.game_releases_url).await?;
let result = download_latest_release(releases, OS).await;
let result = download_latest_release(releases, OS, args.allow_release_candidates).await;

if let Ok(path) = result {
install_archive(path);
Expand All @@ -49,7 +53,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
info!("Starting launcher update...");

let releases = fetch_releases(&args.launcher_releases_url).await?;
let result = download_latest_release(releases, OS).await;
let result = download_latest_release(releases, OS, args.allow_release_candidates).await;

if let Ok(path) = result {
install_archive(path);
Expand Down
7 changes: 5 additions & 2 deletions SOEdownload_manager/src/updater/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ use std::path::{Path, PathBuf};
use super::github::release::Releases;
use log::{error, info};

pub async fn download_latest_release(mut releases: Releases, file_name_contains:&str) -> Result<PathBuf, ()> {
releases.retain(|release| !release.is_prerelease());
pub async fn download_latest_release(mut releases: Releases, file_name_contains:&str, allow_release_candidates:bool) -> Result<PathBuf, ()> {

if !allow_release_candidates {
releases.retain(|release| !release.is_prerelease());
}

if releases.is_empty() {
error!("There is no stable release in the specified repository");
Expand Down

0 comments on commit d25160a

Please sign in to comment.