Skip to content

Commit 7b49d62

Browse files
committed
Avoid mutating ServerStats in ServerInfo::new
1 parent 0f43116 commit 7b49d62

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/server.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,12 +1941,13 @@ fn set_percentage_stat(
19411941
}
19421942

19431943
impl ServerInfo {
1944-
pub async fn new(mut stats: ServerStats, storage: Option<&dyn Storage>) -> Result<Self> {
1944+
pub async fn new(stats: ServerStats, storage: Option<&dyn Storage>) -> Result<Self> {
19451945
let cache_location;
19461946
let use_preprocessor_cache_mode;
19471947
let cache_size;
19481948
let max_cache_size;
19491949
let basedirs;
1950+
let multi_level;
19501951
if let Some(storage) = storage {
19511952
cache_location = storage.location();
19521953
use_preprocessor_cache_mode = storage
@@ -1959,18 +1960,18 @@ impl ServerInfo {
19591960
.iter()
19601961
.map(|p| String::from_utf8_lossy(p).to_string())
19611962
.collect();
1962-
// Get multi-level stats if available
1963-
stats.multi_level = storage.multilevel_stats();
1963+
multi_level = storage.multilevel_stats();
19641964
} else {
19651965
cache_location = String::new();
19661966
use_preprocessor_cache_mode = false;
19671967
cache_size = None;
19681968
max_cache_size = None;
19691969
basedirs = Vec::new();
1970+
multi_level = None;
19701971
}
19711972
let version = env!("CARGO_PKG_VERSION").to_string();
19721973
Ok(ServerInfo {
1973-
stats,
1974+
stats: ServerStats { multi_level, ..stats },
19741975
cache_location,
19751976
cache_size,
19761977
max_cache_size,

0 commit comments

Comments
 (0)