Skip to content

Commit

Permalink
refactor: Move convert_release_candidate_number (#629)
Browse files Browse the repository at this point in the history
to `util` module
  • Loading branch information
GeckoEidechse authored Oct 13, 2023
1 parent 1b656b8 commit 1f3c3f0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
9 changes: 0 additions & 9 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,6 @@ fn main() {
};
}

/// Helps with converting release candidate numbers which are different on Thunderstore
/// due to restrictions imposed by the platform
pub fn convert_release_candidate_number(version_number: String) -> String {
// This simply converts `-rc` to `0`
// Works as intended for RCs < 10, e.g. `v1.9.2-rc1` -> `v1.9.201`
// Doesn't work for larger numbers, e.g. `v1.9.2-rc11` -> `v1.9.2011` (should be `v1.9.211`)
version_number.replace("-rc", "0").replace("00", "")
}

/// Defines how Titanfall2 was installed (Steam, Origin, ...)
#[derive(Serialize, Deserialize, Debug, Clone, TS)]
#[ts(export)]
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/northstar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub async fn check_is_northstar_outdated(
};

// Release candidate version numbers are different between `mods.json` and Thunderstore
let version_number = crate::convert_release_candidate_number(version_number);
let version_number = crate::util::convert_release_candidate_number(version_number);

if version_number != nmod.latest {
log::info!("Installed Northstar version outdated");
Expand Down
9 changes: 9 additions & 0 deletions src-tauri/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,12 @@ pub fn move_dir_all(
}
Ok(())
}

/// Helps with converting release candidate numbers which are different on Thunderstore
/// due to restrictions imposed by the platform
pub fn convert_release_candidate_number(version_number: String) -> String {
// This simply converts `-rc` to `0`
// Works as intended for RCs < 10, e.g. `v1.9.2-rc1` -> `v1.9.201`
// Doesn't work for larger numbers, e.g. `v1.9.2-rc11` -> `v1.9.2011` (should be `v1.9.211`)
version_number.replace("-rc", "0").replace("00", "")
}

0 comments on commit 1f3c3f0

Please sign in to comment.