mirror of
https://github.com/forkless/NotAlterra.git
synced 2026-08-16 08:36:37 +02:00
Require actual .ini files in backup before allowing delete
This commit is contained in:
+9
-1
@@ -867,7 +867,15 @@ fn ini_delete_action<B: Backend>(
|
||||
let has_backup = backup_root.exists()
|
||||
&& std::fs::read_dir(backup_root)
|
||||
.map(|entries| entries.flatten().any(|e| {
|
||||
e.file_name().to_string_lossy().starts_with("ini_backup_")
|
||||
let file_name = e.file_name();
|
||||
let name = file_name.to_string_lossy();
|
||||
name.starts_with("ini_backup_")
|
||||
&& e.path().is_dir()
|
||||
&& std::fs::read_dir(e.path()).map_or(false, |mut d| {
|
||||
d.any(|f| f.ok().map_or(false, |f| {
|
||||
f.file_name().to_string_lossy().ends_with(".ini")
|
||||
}))
|
||||
})
|
||||
}))
|
||||
.unwrap_or(false);
|
||||
|
||||
|
||||
+18
-6
@@ -232,9 +232,15 @@ pub fn delete_ini_files(config_path: &Path, backup_root: &Path) -> Result<usize>
|
||||
&& fs::read_dir(backup_root)
|
||||
.map(|entries| {
|
||||
entries.flatten().any(|e| {
|
||||
e.file_name()
|
||||
.to_string_lossy()
|
||||
.starts_with("ini_backup_")
|
||||
let file_name = e.file_name();
|
||||
let name = file_name.to_string_lossy();
|
||||
name.starts_with("ini_backup_")
|
||||
&& e.path().is_dir()
|
||||
&& std::fs::read_dir(e.path()).map_or(false, |mut d| {
|
||||
d.any(|f| f.ok().map_or(false, |f| {
|
||||
f.file_name().to_string_lossy().ends_with(".ini")
|
||||
}))
|
||||
})
|
||||
})
|
||||
})
|
||||
.unwrap_or(false);
|
||||
@@ -416,9 +422,15 @@ pub fn folder_stats(
|
||||
&& fs::read_dir(backup_root)
|
||||
.map(|entries| {
|
||||
entries.flatten().any(|e| {
|
||||
e.file_name()
|
||||
.to_string_lossy()
|
||||
.starts_with("ini_backup_")
|
||||
let file_name = e.file_name();
|
||||
let name = file_name.to_string_lossy();
|
||||
name.starts_with("ini_backup_")
|
||||
&& e.path().is_dir()
|
||||
&& std::fs::read_dir(e.path()).map_or(false, |mut d| {
|
||||
d.any(|f| f.ok().map_or(false, |f| {
|
||||
f.file_name().to_string_lossy().ends_with(".ini")
|
||||
}))
|
||||
})
|
||||
})
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
||||
Reference in New Issue
Block a user