Files
coa-server-manager/src-tauri/src/window_preferences.rs
T
ДмитрийandClaude Opus 5.5 d64fdb51be Client: clear the game cache on Play, remember the friend's server login
- clear_game_cache removes Cache/WDB/<locale>/*.wdb before every Play (own server and
  friend's), on by default, switch in the client card; nothing else in Cache or Data.
- The connection profile keeps the listed realm it was joined through; Play fills that
  realm's saved account into GlueConfig.json every time. A host typed by hand drops it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 20:51:40 +05:00

26 lines
937 B
Rust

use std::path::Path;
pub fn close_to_tray(dir: &Path) -> coa_core::Result<bool> {
match std::fs::read(dir.join("close-to-tray.json")) {
Ok(bytes) => Ok(serde_json::from_slice(&bytes)?),
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(false),
Err(e) => Err(e.into()),
}
}
pub fn save(dir: &Path, enabled: bool) -> coa_core::Result<()> {
coa_core::fsx::atomic_write_json(&dir.join("close-to-tray.json"), &enabled)
}
/// Clear the game's cache of server data before every Play (on unless the player turned it off).
pub fn clear_cache_on_play(dir: &Path) -> bool {
std::fs::read(dir.join("clear-game-cache.json"))
.ok()
.and_then(|bytes| serde_json::from_slice(&bytes).ok())
.unwrap_or(true)
}
pub fn save_clear_cache_on_play(dir: &Path, enabled: bool) -> coa_core::Result<()> {
coa_core::fsx::atomic_write_json(&dir.join("clear-game-cache.json"), &enabled)
}