diff options
| author | 2025-01-18 23:47:48 -0600 | |
|---|---|---|
| committer | 2025-01-18 23:47:48 -0600 | |
| commit | cd8bf1667494070c3a22ab5d63b559a9742b8a1a (patch) | |
| tree | 6f93f0c0fbdccfa18733499845a8bc7c298c402f /src/launcher/version.rs | |
| parent | building classpath (diff) | |
more stuff
Diffstat (limited to 'src/launcher/version.rs')
| -rw-r--r-- | src/launcher/version.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/launcher/version.rs b/src/launcher/version.rs index 2e320f2..f857b93 100644 --- a/src/launcher/version.rs +++ b/src/launcher/version.rs @@ -7,6 +7,7 @@ use std::path::{Path, PathBuf}; use log::{debug, info, warn}; use sha1_smol::Digest; use tokio::{fs, io}; +use crate::launcher::settings::ProfileVersion; use crate::util; use crate::version::{*, manifest::*}; @@ -234,8 +235,6 @@ impl Display for VersionResolveError { impl Error for VersionResolveError {} - - impl VersionList { async fn create_dir_for(home: &Path) -> Result<(), io::Error> { debug!("Creating versions directory."); @@ -285,6 +284,14 @@ impl VersionList { .map_or_else(|| self.local.versions.get(id).into(), |r| r.versions.get(id).into()) } + pub fn get_profile_version_id<'v>(&self, ver: &'v ProfileVersion) -> Option<Cow<'v, str>> { + match ver { + ProfileVersion::LatestRelease => self.remote.as_ref().map_or(None, |r| Some(Cow::Owned(r.latest.release.clone()))), + ProfileVersion::LatestSnapshot => self.remote.as_ref().map_or(None, |r| Some(Cow::Owned(r.latest.snapshot.clone()))), + ProfileVersion::Specific(ver) => Some(Cow::Borrowed(ver)) + } + } + pub fn get_remote_version(&self, id: &str) -> Option<&VersionManifestVersion> { let remote = self.remote.as_ref().expect("get_remote_version called in offline mode!"); |
