diff --git a/crates/horizon-client/src/command_storage.rs b/crates/horizon-client/src/command_storage.rs index ce6e88f5c..560423e90 100644 --- a/crates/horizon-client/src/command_storage.rs +++ b/crates/horizon-client/src/command_storage.rs @@ -55,7 +55,7 @@ impl CommandStorage { .iter() .map(|(k, v)| (k.as_str().into(), v.clone())) .collect(); - let _ = save::write_dat( + if let Err(e) = save::write_dat( &file(root, namespace), Tag::compound([ ( @@ -64,7 +64,9 @@ impl CommandStorage { ), ("DataVersion", Tag::Int(horizon_world::DATA_VERSION)), ]), - ); + ) { + log::warn!("command storage {namespace} was not written: {e}"); + } } } /// `get`: an empty compound when unset. diff --git a/crates/horizon-client/src/game/bossbars.rs b/crates/horizon-client/src/game/bossbars.rs index 51b64604f..c6acb9616 100644 --- a/crates/horizon-client/src/game/bossbars.rs +++ b/crates/horizon-client/src/game/bossbars.rs @@ -54,13 +54,15 @@ impl Game<'_> { if self.bosses.bars.bars.is_empty() && !self.bossbar_path().exists() { return; } - let _ = save::write_dat( + if let Err(e) = save::write_dat( &self.bossbar_path(), Tag::compound([ ("data", self.bosses.bars.pack()), ("DataVersion", Tag::Int(horizon_world::DATA_VERSION)), ]), - ); + ) { + log::warn!("boss bars were not written: {e}"); + } } pub(in crate::game) fn bossbar_exists(&self, id: &str) -> bool { self.bosses.bars.get(id).is_some() diff --git a/crates/horizon-client/src/game/chat.rs b/crates/horizon-client/src/game/chat.rs index 1bc30513b..ec85732ae 100644 --- a/crates/horizon-client/src/game/chat.rs +++ b/crates/horizon-client/src/game/chat.rs @@ -822,8 +822,12 @@ impl Game<'_> { ("data", data), ("DataVersion", Tag::Int(horizon_world::DATA_VERSION)), ]); - let _ = horizon_client::save::write_dat(&path, root); - let _ = write_difficulty(&self.world_root, self.ui.difficulty); + if let Err(e) = horizon_client::save::write_dat(&path, root) { + log::warn!("the world clocks were not written: {e}"); + } + if let Err(e) = write_difficulty(&self.world_root, self.ui.difficulty) { + log::warn!("the difficulty was not written: {e}"); + } } /// Death message in chat (CombatTracker.getDeathMessage, as far as the /// cause is known to the client). diff --git a/crates/horizon-client/src/game/debug_keys.rs b/crates/horizon-client/src/game/debug_keys.rs index e0ad706de..61e2b2f05 100644 --- a/crates/horizon-client/src/game/debug_keys.rs +++ b/crates/horizon-client/src/game/debug_keys.rs @@ -185,7 +185,9 @@ impl Game<'_> { // Minecraft.emergencySaveAndCrash: the world is saved, then the // game stops; main writes the crash report. let crash = horizon_client::crash::DebugCrash::new(); - let _ = self.save_game(); + if let Err(e) = self.save_game() { + log::error!("the emergency save before the crash failed: {e}"); + } return Err(crash.into()); } } diff --git a/crates/horizon-client/src/game/dedicated.rs b/crates/horizon-client/src/game/dedicated.rs index 4c436c60c..9cc892fe0 100644 --- a/crates/horizon-client/src/game/dedicated.rs +++ b/crates/horizon-client/src/game/dedicated.rs @@ -218,21 +218,22 @@ impl Lists { use_whitelist: false, enforce_whitelist: false, }; + // DedicatedPlayerList's constructor order and its LOGGER.warn lines. let warn = |what: &str, r: std::result::Result<(), String>| { if let Err(e) = r { - log("WARN", &format!("Failed to load {what}: {e}")); + log("WARN", &format!("Failed to {what}: {e}")); } }; - // DedicatedPlayerList's constructor order. - warn("user banlist", l.bans.load()); - let _ = l.bans.save(); - warn("ip banlist", l.ip_bans.load()); - let _ = l.ip_bans.save(); - warn("operators list", l.ops.load()); - warn("white-list", l.white.load()); - let _ = l.ops.save(); + let saved = |r: std::io::Result<()>| r.map_err(|e| e.to_string()); + warn("load user banlist", l.bans.load()); + warn("save user banlist", saved(l.bans.save())); + warn("load ip banlist", l.ip_bans.load()); + warn("save ip banlist", saved(l.ip_bans.save())); + warn("load operators list", l.ops.load()); + warn("load white-list", l.white.load()); + warn("save operators list", saved(l.ops.save())); if !l.white.file.exists() { - let _ = l.white.save(); + warn("save white-list", saved(l.white.save())); } l } diff --git a/crates/horizon-client/src/save.rs b/crates/horizon-client/src/save.rs index 7819a9b0b..da5735c17 100644 --- a/crates/horizon-client/src/save.rs +++ b/crates/horizon-client/src/save.rs @@ -1913,7 +1913,8 @@ pub fn write_dat(path: &Path, tag: Tag) -> Result<()> { Some(stem) => path.with_file_name(format!("{stem}.dat_old")), None => path.with_file_name(format!("{file}_old")), }; - let _ = fs::rename(path, old); + // Util.safeReplaceFile: no backup, no replacement. + fs::rename(path, old).map_err(|e| format!("{}: {e}", path.display()))?; } fs::rename(temporary, path)?; Ok(())