mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
fix(gui-client): delete crash dumps when deleting logs (#6281)
This was a regression in a recent PR
This commit is contained in:
@@ -167,19 +167,15 @@ fn choose_logs_to_delete(paths: &[PathBuf]) -> Vec<&Path> {
|
||||
|
||||
paths
|
||||
.iter()
|
||||
.filter(|path| {
|
||||
let Some(stem) = path.file_stem() else {
|
||||
return false;
|
||||
};
|
||||
let Some(stem) = stem.to_str() else {
|
||||
return false;
|
||||
};
|
||||
.filter_map(|path| {
|
||||
// Don't delete files if we can't parse their stems as UTF-8.
|
||||
let stem = path.file_stem()?.to_str()?;
|
||||
if !stem.starts_with("connlib.") {
|
||||
return false;
|
||||
// Delete any non-log files like crash dumps.
|
||||
return Some(path.as_path());
|
||||
}
|
||||
stem < most_recent_stem
|
||||
(stem < most_recent_stem).then_some(path.as_path())
|
||||
})
|
||||
.map(|x| x.as_path())
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -344,6 +340,8 @@ mod tests {
|
||||
"/bogus/connlib.2024-08-06-14-21-13.log",
|
||||
"/bogus/connlib.2024-08-06-14-51-19.jsonl",
|
||||
"/bogus/connlib.2024-08-06-14-51-19.log",
|
||||
"/bogus/crash.2024-07-22-21-16-20.dmp",
|
||||
"/bogus/last_crash.dmp",
|
||||
]
|
||||
.into_iter()
|
||||
.map(Path::new)
|
||||
|
||||
Reference in New Issue
Block a user