diff options
| author | Filip Wandzio <contact@philw.dev> | 2026-02-03 16:34:38 +0100 |
|---|---|---|
| committer | Filip Wandzio <contact@philw.dev> | 2026-02-03 16:34:38 +0100 |
| commit | c97d9c3b01133493b30baeec912c496867873dc5 (patch) | |
| tree | f0f06bb55c88de4ba6d9c09179ee1822e8fdf78f /src/minecraft/downloads.rs | |
| parent | a393e0a2f2c3678a3ea869dc1417fa269f2b1040 (diff) | |
| download | dml-c97d9c3b01133493b30baeec912c496867873dc5.tar.gz dml-c97d9c3b01133493b30baeec912c496867873dc5.zip | |
Purge leftover comments
Diffstat (limited to 'src/minecraft/downloads.rs')
| -rw-r--r-- | src/minecraft/downloads.rs | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/src/minecraft/downloads.rs b/src/minecraft/downloads.rs index a994146..7017d3f 100644 --- a/src/minecraft/downloads.rs +++ b/src/minecraft/downloads.rs | |||
| @@ -16,7 +16,7 @@ use crate::{ | |||
| 16 | #[derive(Debug, Deserialize)] | 16 | #[derive(Debug, Deserialize)] |
| 17 | struct AssetObject { | 17 | struct AssetObject { |
| 18 | hash: String, | 18 | hash: String, |
| 19 | size: u64, | 19 | // size: u64, |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | #[derive(Debug, Deserialize)] | 22 | #[derive(Debug, Deserialize)] |
| @@ -24,10 +24,6 @@ struct AssetIndexManifest { | |||
| 24 | objects: std::collections::HashMap<String, AssetObject>, | 24 | objects: std::collections::HashMap<String, AssetObject>, |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | /// Pobiera wszystko potrzebne do uruchomienia Minecraft: | ||
| 28 | /// - client jar | ||
| 29 | /// - biblioteki (artifact + natives) | ||
| 30 | /// - assets (w tym textures, sounds) | ||
| 31 | pub async fn download_all( | 27 | pub async fn download_all( |
| 32 | config: &Config, | 28 | config: &Config, |
| 33 | version: &Version, | 29 | version: &Version, |
| @@ -58,7 +54,6 @@ async fn download_libraries( | |||
| 58 | libraries: &[Library], | 54 | libraries: &[Library], |
| 59 | ) -> Result<(), McError> { | 55 | ) -> Result<(), McError> { |
| 60 | for library in libraries { | 56 | for library in libraries { |
| 61 | // ===== CLASSPATH LIBRARIES ===== | ||
| 62 | if let Some(artifact) = &library.downloads.artifact { | 57 | if let Some(artifact) = &library.downloads.artifact { |
| 63 | let library_path = paths::library_file(config, &artifact.path)?; | 58 | let library_path = paths::library_file(config, &artifact.path)?; |
| 64 | 59 | ||
| @@ -68,7 +63,6 @@ async fn download_libraries( | |||
| 68 | } | 63 | } |
| 69 | } | 64 | } |
| 70 | 65 | ||
| 71 | // ===== NATIVES ===== | ||
| 72 | if let Some(classifiers) = &library.downloads.classifiers { | 66 | if let Some(classifiers) = &library.downloads.classifiers { |
| 73 | for (_, native) in classifiers { | 67 | for (_, native) in classifiers { |
| 74 | let native_path = paths::library_file(config, &native.path)?; | 68 | let native_path = paths::library_file(config, &native.path)?; |
| @@ -97,7 +91,6 @@ async fn download_asset_index( | |||
| 97 | McError::Config("Missing asset_index in version.json".into()) | 91 | McError::Config("Missing asset_index in version.json".into()) |
| 98 | })?; | 92 | })?; |
| 99 | 93 | ||
| 100 | // Nie pozwalamy na legacy dla nowoczesnych wersji | ||
| 101 | if asset_index.id == "legacy" { | 94 | if asset_index.id == "legacy" { |
| 102 | return Err(McError::Config( | 95 | return Err(McError::Config( |
| 103 | "Legacy assetIndex detected – pobierz właściwy version.json".into(), | 96 | "Legacy assetIndex detected – pobierz właściwy version.json".into(), |
| @@ -108,14 +101,12 @@ async fn download_asset_index( | |||
| 108 | .join("indexes") | 101 | .join("indexes") |
| 109 | .join(format!("{}.json", asset_index.id)); | 102 | .join(format!("{}.json", asset_index.id)); |
| 110 | 103 | ||
| 111 | // Jeśli indeks istnieje lokalnie | ||
| 112 | if index_path.exists() { | 104 | if index_path.exists() { |
| 113 | let index_data = fs::read_to_string(&index_path).await?; | 105 | let index_data = fs::read_to_string(&index_path).await?; |
| 114 | let manifest: AssetIndexManifest = serde_json::from_str(&index_data)?; | 106 | let manifest: AssetIndexManifest = serde_json::from_str(&index_data)?; |
| 115 | return Ok(manifest); | 107 | return Ok(manifest); |
| 116 | } | 108 | } |
| 117 | 109 | ||
| 118 | // Pobierz indeks z sieci | ||
| 119 | info!("Downloading asset index {}", asset_index.id); | 110 | info!("Downloading asset index {}", asset_index.id); |
| 120 | let response = get(&asset_index.url).await?; | 111 | let response = get(&asset_index.url).await?; |
| 121 | let manifest_text = response.text().await?; | 112 | let manifest_text = response.text().await?; |
| @@ -132,13 +123,11 @@ async fn download_assets( | |||
| 132 | ) -> Result<(), McError> { | 123 | ) -> Result<(), McError> { |
| 133 | let assets_dir = paths::assets_dir(config); | 124 | let assets_dir = paths::assets_dir(config); |
| 134 | 125 | ||
| 135 | // Katalogi MUSZĄ istnieć | ||
| 136 | create_dir_all(assets_dir.join("objects")).await?; | 126 | create_dir_all(assets_dir.join("objects")).await?; |
| 137 | create_dir_all(assets_dir.join("indexes")).await?; | 127 | create_dir_all(assets_dir.join("indexes")).await?; |
| 138 | 128 | ||
| 139 | let manifest = download_asset_index(config, version).await?; | 129 | let manifest = download_asset_index(config, version).await?; |
| 140 | 130 | ||
| 141 | // Pobieramy wszystkie obiekty | ||
| 142 | for (logical_path, asset) in &manifest.objects { | 131 | for (logical_path, asset) in &manifest.objects { |
| 143 | let subdir = &asset.hash[0..2]; | 132 | let subdir = &asset.hash[0..2]; |
| 144 | let file_path = assets_dir | 133 | let file_path = assets_dir |
| @@ -158,7 +147,6 @@ async fn download_assets( | |||
| 158 | download_file(&url, &file_path).await?; | 147 | download_file(&url, &file_path).await?; |
| 159 | } | 148 | } |
| 160 | 149 | ||
| 161 | // Pobierz sounds.json jeśli istnieje | ||
| 162 | if let Some(asset) = manifest.objects.get("sounds.json") { | 150 | if let Some(asset) = manifest.objects.get("sounds.json") { |
| 163 | let file_path = assets_dir.join("indexes").join("sounds.json"); | 151 | let file_path = assets_dir.join("indexes").join("sounds.json"); |
| 164 | if !file_path.exists() { | 152 | if !file_path.exists() { |
| @@ -175,7 +163,6 @@ async fn download_assets( | |||
| 175 | Ok(()) | 163 | Ok(()) |
| 176 | } | 164 | } |
| 177 | 165 | ||
| 178 | /// Helper do pobierania plików | ||
| 179 | async fn download_file( | 166 | async fn download_file( |
| 180 | url: &str, | 167 | url: &str, |
| 181 | path: &std::path::Path, | 168 | path: &std::path::Path, |
