diff options
| author | 2025-01-31 02:32:19 -0600 | |
|---|---|---|
| committer | 2025-01-31 02:32:19 -0600 | |
| commit | cdeee17c2be5b8b9a333b977b3e2d373b94dfe0a (patch) | |
| tree | 58ec48b5bfa9afe03ebbd9716f1f90841af914e9 /src/launcher/jre.rs | |
| parent | Remove some unused imports but not all of them (diff) | |
do clippy stuff and change line endings
Diffstat (limited to 'src/launcher/jre.rs')
| -rw-r--r-- | src/launcher/jre.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/launcher/jre.rs b/src/launcher/jre.rs index 0b92c20..31034b5 100644 --- a/src/launcher/jre.rs +++ b/src/launcher/jre.rs @@ -67,13 +67,13 @@ impl JavaRuntimeRepository { .inspect_err(|e| warn!("Failed to create directory for JRE component {}: {}", component, e)) .map_err(|e| JavaRuntimeError::IO { what: "creating component directory", error: e })?; - util::ensure_file(&manifest_path, info.url.as_ref().map(|s| s.as_str()), info.size, info.sha1, self.online, false).await + util::ensure_file(&manifest_path, info.url.as_deref(), info.size, info.sha1, self.online, false).await .map_err(JavaRuntimeError::EnsureFile)?; let manifest_file = fs::read_to_string(&manifest_path).await .map_err(|e| JavaRuntimeError::IO { what: "reading runtimes manifest", error: e })?; - Ok(serde_json::from_str(&manifest_file).map_err(|e| JavaRuntimeError::Deserialize { what: "runtime manifest", error: e })?) + serde_json::from_str(&manifest_file).map_err(|e| JavaRuntimeError::Deserialize { what: "runtime manifest", error: e }) } // not very descriptive function name @@ -86,7 +86,7 @@ impl JavaRuntimeRepository { return Err(JavaRuntimeError::UnsupportedComponent { arch: JRE_ARCH, component: component.to_owned() }); }; - let Some(runtime) = runtime_component.iter().filter(|r| r.availability.progress == 100).next() else { + let Some(runtime) = runtime_component.iter().find(|r| r.availability.progress == 100) else { if !runtime_components.is_empty() { warn!("Weird: the only java runtimes in {JRE_ARCH}.{component} has a progress of less than 100!"); } @@ -102,17 +102,16 @@ impl JavaRuntimeRepository { let entry = entry?; let rel_path = entry.path().strip_prefix(path).expect("walkdir escaped root (???)"); - if rel_path.components().filter(|c| !matches!(c, Component::CurDir)).next().is_none() { + if !rel_path.components().any(|c| !matches!(&c, Component::CurDir)) { // if this path is trivial (points at the root), ignore it continue; } - let rel_path_str; - if std::path::MAIN_SEPARATOR != '/' { - rel_path_str = rel_path.to_str().map(|s| s.replace(std::path::MAIN_SEPARATOR, "/")); + let rel_path_str = if std::path::MAIN_SEPARATOR != '/' { + rel_path.to_str().map(|s| s.replace(std::path::MAIN_SEPARATOR, "/")) } else { - rel_path_str = rel_path.to_str().map(String::from); - } + rel_path.to_str().map(String::from) + }; if !rel_path_str.as_ref().is_some_and(|s| manifest.files.get(s) .is_some_and(|f| (f.is_file() == entry.file_type().is_file()) @@ -175,7 +174,7 @@ impl JavaRuntimeRepository { Err(e) if e.kind() == ErrorKind::AlreadyExists => Ok(()), Err(e) => { warn!("Could not create directory {} for JRE!", ent_path.display()); - return Err(JavaRuntimeError::IO { what: "creating directory", error: e }); + Err(JavaRuntimeError::IO { what: "creating directory", error: e }) } } }).await |
