diff options
Diffstat (limited to 'src/launcher.rs')
| -rw-r--r-- | src/launcher.rs | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/launcher.rs b/src/launcher.rs index a7ef8c9..a849cc5 100644 --- a/src/launcher.rs +++ b/src/launcher.rs @@ -22,8 +22,9 @@ use tokio::{fs, io}; use tokio::io::AsyncReadExt; use version::VersionList; use profile::{Instance, Profile}; +use crate::launcher::download::{Download, VerifiedDownload}; use crate::launcher::version::{VersionResolveError, VersionResult}; -use crate::version::{Library, OSRestriction, OperatingSystem}; +use crate::version::{DownloadInfo, Library, OSRestriction, OperatingSystem}; #[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct Settings { @@ -72,8 +73,7 @@ impl Settings { struct SystemInfo { os: OperatingSystem, os_version: String, - arch: String, - arch_bits: usize + arch: String } struct LibraryRepository { @@ -155,7 +155,9 @@ impl Launcher { settings_path, settings, system_info: SystemInfo::new(), - libraries: LibraryRepository { home: home.join("libraries") } + libraries: LibraryRepository { + home: home.join("libraries"), + } }) } @@ -195,6 +197,8 @@ impl Launcher { let ver = self.versions.resolve_version(ver.as_ref()).await.map_err(|e| LaunchError::ResolveVersion(e))?; + // todo: make a list of all the required libraries + todo!() } } @@ -258,6 +262,22 @@ impl LibraryRepository { p.push(Self::get_artifact_filename(name, classifier)?); Some(p) } + + fn create_download(&self, lib: &Library, os: OperatingSystem) -> Option<VerifiedDownload> { + let classifier = lib.natives.as_ref()?.get(&os).map(|s| s.as_str()); + + if lib.url.is_some() || lib.downloads.is_none() { + // TODO: derive download URL in this situation? + warn!("BUG: Deprecated case for library {}: url present or downloads missing. The launcher does not support out-of-line checksums at this time. Not downloading this library.", lib.name); + return None; + } + + let dlinfo = lib.downloads.as_ref()?.get_download_info(classifier)?; + // drinking game: take a shot once per heap allocation + let path = self.home.join(dlinfo.path.as_ref().map(PathBuf::from).or_else(|| Self::get_artifact_path(lib.name.as_str(), classifier))?); + + Some(VerifiedDownload::new(dlinfo.url.as_ref()?, path.as_path(), dlinfo.size, dlinfo.sha1)) + } } impl SystemInfo { @@ -283,8 +303,7 @@ impl SystemInfo { SystemInfo { os, os_version, - arch, - arch_bits: size_of::<*const i32>() * 8 + arch } } |
