Dedicated: the list saves log vanilla's warnings
DedicatedPlayerList logs "Failed to save user banlist: " (and ip banlist, operators list, white-list) when a startup save fails; the shared closure printed "Failed to load user banlist write". The closure now takes the verb, so loads and saves read as vanilla's lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -218,30 +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());
|
||||
warn(
|
||||
"user banlist write",
|
||||
l.bans.save().map_err(|e| e.to_string()),
|
||||
);
|
||||
warn("ip banlist", l.ip_bans.load());
|
||||
warn(
|
||||
"ip banlist write",
|
||||
l.ip_bans.save().map_err(|e| e.to_string()),
|
||||
);
|
||||
warn("operators list", l.ops.load());
|
||||
warn("white-list", l.white.load());
|
||||
warn("operators write", l.ops.save().map_err(|e| e.to_string()));
|
||||
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() {
|
||||
warn(
|
||||
"white-list write",
|
||||
l.white.save().map_err(|e| e.to_string()),
|
||||
);
|
||||
warn("save white-list", saved(l.white.save()));
|
||||
}
|
||||
l
|
||||
}
|
||||
|
||||
@@ -1913,9 +1913,7 @@ 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")),
|
||||
};
|
||||
// Vanilla's safeReplaceFile moves the current file aside first. This used to be
|
||||
// swallowed, and the rename below then failed on the existing path with nothing
|
||||
// reporting it: a save that could not happen looked like one that did.
|
||||
// Util.safeReplaceFile: no backup, no replacement.
|
||||
fs::rename(path, old).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||
}
|
||||
fs::rename(temporary, path)?;
|
||||
|
||||
Reference in New Issue
Block a user