fix: resolve clippy issues
This commit is contained in:
1 parent
eb91c908fc
commit
971375bf1f
18 files changed
+80
-116
No files matched your search
@@ -18,11 +18,7 @@ pub(crate) fn parse_enabled_stem(file_name: &str, ext: &str) -> Option<(bool, St
|
||||
let disabled_ext = format!("{ext}.disabled");
|
||||
if let Some(stem) = file_name.strip_suffix(&disabled_ext) {
|
||||
Some((false, stem.to_string()))
|
||||
} else if let Some(stem) = file_name.strip_suffix(ext) {
|
||||
Some((true, stem.to_string()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else { file_name.strip_suffix(ext).map(|stem| (true, stem.to_string())) }
|
||||
}
|
||||
|
||||
/// For directories: check if the name ends in `.disabled`.
|
||||
|
||||
@@ -71,17 +71,15 @@ fn world_description(world_dir: &Path) -> String {
|
||||
|
||||
let mut lines = Vec::new();
|
||||
|
||||
if let Some(secs) = created {
|
||||
if let Some(dt) = chrono::DateTime::from_timestamp(secs as i64, 0) {
|
||||
if let Some(secs) = created
|
||||
&& let Some(dt) = chrono::DateTime::from_timestamp(secs as i64, 0) {
|
||||
lines.push(format!("Created: {}", dt.format("%Y-%m-%d %H:%M")));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(secs) = modified {
|
||||
if let Some(dt) = chrono::DateTime::from_timestamp(secs as i64, 0) {
|
||||
if let Some(secs) = modified
|
||||
&& let Some(dt) = chrono::DateTime::from_timestamp(secs as i64, 0) {
|
||||
lines.push(format!("Played: {}", dt.format("%Y-%m-%d %H:%M")));
|
||||
}
|
||||
}
|
||||
|
||||
if dir_size > 0 {
|
||||
lines.push(format!("Size: {}", format_size(dir_size)));
|
||||
@@ -94,11 +92,10 @@ fn dir_size_approx(path: &Path) -> u64 {
|
||||
let mut total = 0u64;
|
||||
if let Ok(rd) = std::fs::read_dir(path) {
|
||||
for entry in rd.flatten() {
|
||||
if let Ok(meta) = entry.metadata() {
|
||||
if meta.is_file() {
|
||||
if let Ok(meta) = entry.metadata()
|
||||
&& meta.is_file() {
|
||||
total += meta.len();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check region folder too (main chunk data)
|
||||
|
||||
@@ -220,8 +220,8 @@ pub async fn launch(
|
||||
}
|
||||
crate::auth::AccountType::Offline => ("0".to_string(), None),
|
||||
};
|
||||
if let Some(new_rt) = new_refresh {
|
||||
if let Some(stored) = account_store
|
||||
if let Some(new_rt) = new_refresh
|
||||
&& let Some(stored) = account_store
|
||||
.accounts
|
||||
.iter_mut()
|
||||
.find(|a| a.uuid == acc.uuid)
|
||||
@@ -229,7 +229,6 @@ pub async fn launch(
|
||||
stored.refresh_token = Some(new_rt);
|
||||
account_store.save();
|
||||
}
|
||||
}
|
||||
let user_type = match acc.account_type {
|
||||
crate::auth::AccountType::Microsoft => "msa",
|
||||
crate::auth::AccountType::Offline => "legacy",
|
||||
@@ -321,11 +320,10 @@ pub async fn launch(
|
||||
while let Ok(Some(line)) = lines.next_line().await {
|
||||
tracing::info!(target: "mc_instance", "[{}] {}", n, line);
|
||||
crate::instance_logs::push(&n, &line);
|
||||
if let Ok(mut f) = w.lock() {
|
||||
if let Some(f) = f.as_mut() {
|
||||
if let Ok(mut f) = w.lock()
|
||||
&& let Some(f) = f.as_mut() {
|
||||
let _ = writeln!(f, "{}", line);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -338,11 +336,10 @@ pub async fn launch(
|
||||
while let Ok(Some(line)) = lines.next_line().await {
|
||||
tracing::warn!(target: "mc_instance", "[{}] {}", n, line);
|
||||
crate::instance_logs::push(&n, &line);
|
||||
if let Ok(mut f) = w.lock() {
|
||||
if let Some(f) = f.as_mut() {
|
||||
if let Ok(mut f) = w.lock()
|
||||
&& let Some(f) = f.as_mut() {
|
||||
let _ = writeln!(f, "[STDERR] {}", line);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -209,8 +209,8 @@ impl InstanceManager {
|
||||
std::fs::rename(&old_dir, &new_dir)?;
|
||||
|
||||
let config_path = new_dir.join("instance.json");
|
||||
if let Ok(data) = std::fs::read_to_string(&config_path) {
|
||||
if let Ok(mut config) = serde_json::from_str::<InstanceConfig>(&data) {
|
||||
if let Ok(data) = std::fs::read_to_string(&config_path)
|
||||
&& let Ok(mut config) = serde_json::from_str::<InstanceConfig>(&data) {
|
||||
config.name = new_name.to_string();
|
||||
if let Ok(json) = serde_json::to_string_pretty(&config) {
|
||||
let _ = std::fs::write(&config_path, json);
|
||||
@@ -219,7 +219,6 @@ impl InstanceManager {
|
||||
tracing::warn!("Failed to rename desktop shortcut: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user