core: show data_dir in config and check its asset policy
'victory config' displays game_dir, cache_dir, and test_titles, but omitted data_dir (where saves, persistent local storage, and crashes.log are stored). It also omitted data_dir from the runtime asset-policy check loop in show_config(). Include data_dir in the output and policy check, and add a unit test in victory-core asserting that a data_dir inside the repository is refused.
This commit is contained in:
1 parent
35e8407c9c
commit
d8177c18d5
2 files changed
+12
-1
No files matched your search
@@ -180,6 +180,7 @@ fn show_config() -> Result<()> {
|
|||||||
);
|
);
|
||||||
println!("game_dir : {}", status(&cfg.game_dir));
|
println!("game_dir : {}", status(&cfg.game_dir));
|
||||||
println!("cache_dir : {}", cfg.cache_dir.display());
|
println!("cache_dir : {}", cfg.cache_dir.display());
|
||||||
|
println!("data_dir : {}", cfg.data_dir.display());
|
||||||
for t in &cfg.test_titles {
|
for t in &cfg.test_titles {
|
||||||
println!("test_title : {}", status(&Some(t.clone())));
|
println!("test_title : {}", status(&Some(t.clone())));
|
||||||
}
|
}
|
||||||
@@ -187,7 +188,7 @@ fn show_config() -> Result<()> {
|
|||||||
.game_dir
|
.game_dir
|
||||||
.iter()
|
.iter()
|
||||||
.chain(&cfg.test_titles)
|
.chain(&cfg.test_titles)
|
||||||
.chain([&cfg.cache_dir])
|
.chain([&cfg.cache_dir, &cfg.data_dir])
|
||||||
{
|
{
|
||||||
if let Err(e) = victory_core::ensure_outside_repo(p) {
|
if let Err(e) = victory_core::ensure_outside_repo(p) {
|
||||||
println!("POLICY VIOLATION: {e}");
|
println!("POLICY VIOLATION: {e}");
|
||||||
|
|||||||
@@ -181,4 +181,14 @@ mod tests {
|
|||||||
};
|
};
|
||||||
assert!(cfg.cache_subdir("x").is_err());
|
assert!(cfg.cache_subdir("x").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn data_inside_repo_is_refused() {
|
||||||
|
let inside = Path::new(env!("CARGO_MANIFEST_DIR")).join("data");
|
||||||
|
let cfg = Config {
|
||||||
|
data_dir: inside,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
assert!(cfg.data_subdir("x").is_err());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user