mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-20 22:40:44 +01:00
Name the exact byte counts in the too-large-to-save error
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8eb2c83e04
commit
8eeb8e5e7e
2 files changed
+4
-1
No files matched your search
@@ -147,7 +147,7 @@ fn check_loadable(pf: &ProjectFile, limit: u64) -> Result<()> {
|
||||
if size > limit {
|
||||
let gib = |b: u64| b as f64 / (1u64 << 30) as f64;
|
||||
return Err(FormatError::TooLarge(format!(
|
||||
"the project holds {:.2} GiB of data once unpacked, but TextureCraft opens project files only up to {:.2} GiB, so nothing was saved and an existing file is unchanged. \
|
||||
"the project holds {:.2} GiB ({size} bytes) of data once unpacked, but TextureCraft opens project files only up to {:.2} GiB ({limit} bytes), so nothing was saved and an existing file is unchanged. \
|
||||
Remove paint layers or baked maps to make it smaller",
|
||||
gib(size),
|
||||
gib(limit)
|
||||
|
||||
@@ -358,6 +358,9 @@ fn a_project_too_big_to_reopen_is_not_saved() {
|
||||
let err = check_loadable(&s.pf, size - 1).unwrap_err();
|
||||
assert!(matches!(err, FormatError::TooLarge(_)));
|
||||
assert!(err.to_string().contains("nothing was saved"), "{err}");
|
||||
// Exact byte counts: a size just over the limit does not read as the limit.
|
||||
let msg = err.to_string();
|
||||
assert!(msg.contains(&format!("({size} bytes)")) && msg.contains(&format!("({} bytes)", size - 1)), "{msg}");
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
|
||||
Reference in new issue
Block a user