* claim: #4086 * Raise the largest file SolidCraft opens with a setting or launch flag (#4086) * Translate the file size limit strings * Size limits: design files are .sc now, .solidcraft still read
This commit is contained in:
1 parent
506f79c092
commit
dd2e44bb12
21 files changed
+985
-89
No files matched your search
@@ -23,6 +23,7 @@
|
||||
//! solidcraft-cli icon --out F.png|F.ico [--size N] the app icon (packaging; drawn, not a file)
|
||||
//!
|
||||
//! --debug (with any command) SolidCraft's debug log on stderr (or RUST_LOG=LEVEL)
|
||||
//! --max-file-size SIZE (with any command) read STEP and design files up to SIZE (2GB, 1500MB; at most 16GB)
|
||||
//! ```
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
#![forbid(unsafe_code)]
|
||||
@@ -99,7 +100,7 @@ const USAGE_BENCH_EDIT: &str = " solidcraft-cli bench-edit <script.json|recipe.
|
||||
/// `save-stress`'s lines in the usage: the file saved over and over.
|
||||
const USAGE_SAVE_STRESS: &str = " solidcraft-cli save-stress <path> <rounds>\n";
|
||||
/// The flags every command takes, at the end of the top-level usage.
|
||||
const USAGE_DEBUG: &str = " --debug, with any command: what SolidCraft logs (why a body has no display plan, why a save left its\n model cache out), on stderr; RUST_LOG=error|warn|info|debug|trace sets one level for every crate\n";
|
||||
const USAGE_DEBUG: &str = " --debug, with any command: what SolidCraft logs (why a body has no display plan, why a save left its\n model cache out), on stderr; RUST_LOG=error|warn|info|debug|trace sets one level for every crate\n --max-file-size SIZE, with any command: read STEP and import files and design files up to SIZE for this run\n (for example 2GB or 1500MB; at most 16GB; the defaults are 512 MB and 256 MB, and a smaller SIZE keeps them)\n";
|
||||
|
||||
/// The commands the CLI takes, in the order the top-level usage lists them.
|
||||
const COMMANDS: &[Command] = &[
|
||||
@@ -131,6 +132,10 @@ const COMMANDS: &[Command] = &[
|
||||
fn main() -> ExitCode {
|
||||
let mut args: Vec<String> = std::env::args().skip(1).collect();
|
||||
logger::init(&mut args);
|
||||
if let Err(e) = max_file_size(&mut args) {
|
||||
eprintln!("error: {e}");
|
||||
return ExitCode::FAILURE;
|
||||
}
|
||||
let r = match args.first().map(String::as_str) {
|
||||
// Asked-for help is not an error: the command's usage on stdout, exit 0. It is read
|
||||
// before the command runs, so `--help` never starts a run (a fuzz run, a server).
|
||||
@@ -205,6 +210,28 @@ fn main() -> ExitCode {
|
||||
}
|
||||
}
|
||||
|
||||
/// Take `--max-file-size SIZE` (or `--max-file-size=SIZE`), which any command takes, out of the
|
||||
/// arguments and raise the file size limits for this run (#4086). A bad size is an error.
|
||||
fn max_file_size(args: &mut Vec<String>) -> Result<(), String> {
|
||||
let mut size = None;
|
||||
let mut i = 0;
|
||||
while let Some(arg) = args.get(i) {
|
||||
if arg == "--max-file-size" {
|
||||
let value = args.get(i + 1).cloned().ok_or("--max-file-size needs a size, for example --max-file-size 2GB")?;
|
||||
args.drain(i..i + 2);
|
||||
size = Some(value);
|
||||
} else if let Some(value) = arg.strip_prefix("--max-file-size=") {
|
||||
size = Some(value.to_string());
|
||||
args.remove(i);
|
||||
} else {
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
let Some(size) = size else { return Ok(()) };
|
||||
let bytes = solidcraft_engine::io::limits::parse_flag(&size).map_err(|e| format!("--max-file-size: {e}"))?;
|
||||
solidcraft_engine::io::limits::set_override(Some(bytes))
|
||||
}
|
||||
|
||||
fn pretty(v: &Value) -> String {
|
||||
serde_json::to_string_pretty(v).unwrap_or_default()
|
||||
}
|
||||
@@ -241,7 +268,8 @@ fn wants_help(args: &[String]) -> bool {
|
||||
pub fn read_json(path: &str) -> Result<Value, String> {
|
||||
// Through the engine's file access, which refuses anything that is not a regular file and
|
||||
// reads no more than the cap: a character device or a FIFO would otherwise never end.
|
||||
let s = solidcraft_engine::io::vfs::read_to_string(path, solidcraft_engine::io::MAX_DESIGN_BYTES).map_err(|e| format!("{path}: {e}"))?;
|
||||
let s = solidcraft_engine::io::vfs::read_to_string(path, solidcraft_engine::io::limits::max_design_bytes())
|
||||
.map_err(|e| format!("{path}: {}", solidcraft_engine::io::limits::explain(solidcraft_engine::io::limits::Kind::Design, e)))?;
|
||||
serde_json::from_str(&s).map_err(|e| format!("{path}: {e}"))
|
||||
}
|
||||
|
||||
@@ -259,7 +287,7 @@ fn load_checked(path: &str, check: solidcraft_engine::schema::ParamCheck) -> Res
|
||||
s.execute("doc.open", &json!({"path": path})).map_err(|e| e.to_string())?;
|
||||
return Ok(s);
|
||||
}
|
||||
let bytes = solidcraft_engine::io::vfs::read(path, solidcraft_engine::io::MAX_DESIGN_BYTES).map_err(|e| format!("{path}: {e}"))?;
|
||||
let bytes = solidcraft_engine::io::limits::read(path, solidcraft_engine::io::limits::Kind::Design).map_err(|e| format!("{path}: {e}"))?;
|
||||
if solidcraft_engine::io::is_design_container(&bytes) {
|
||||
let doc = solidcraft_engine::io::read_design(&bytes).map_err(|e| format!("{path}: {e}"))?;
|
||||
let mut session = Session::opened_at(doc, None, Some(path));
|
||||
@@ -820,8 +848,8 @@ pub(crate) fn cmd_bench_open(args: &[String]) -> Result<(), String> {
|
||||
let path = args.first().ok_or("usage: solidcraft-cli bench-open <design.sc | part.step> [--parse-only]")?;
|
||||
let t = std::time::Instant::now();
|
||||
let step = solidcraft_engine::io::is_step_path(path);
|
||||
let limit = if step { solidcraft_engine::io::MAX_STEP_BYTES } else { solidcraft_engine::io::MAX_DESIGN_BYTES };
|
||||
let bytes = solidcraft_engine::io::vfs::read(path, limit).map_err(|e| format!("{path}: {e}"))?;
|
||||
let kind = if step { solidcraft_engine::io::limits::Kind::Step } else { solidcraft_engine::io::limits::Kind::Design };
|
||||
let bytes = solidcraft_engine::io::limits::read(path, kind).map_err(|e| format!("{path}: {e}"))?;
|
||||
let read_ms = t.elapsed().as_secs_f64() * 1000.0;
|
||||
println!("{}", json!({"step": "read", "ms": read_ms, "bytes": bytes.len()}));
|
||||
let t = std::time::Instant::now();
|
||||
|
||||
@@ -157,3 +157,34 @@ fn render_help_keeps_the_registered_gpu_request_controls() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `--max-file-size` (#4086), with any command: the usage names it, a bad size stops the run
|
||||
/// with the reason, and a design over the default limit opens once the flag raises it.
|
||||
#[test]
|
||||
fn max_file_size_raises_the_limit_and_refuses_bad_sizes() {
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_solidcraft-cli")).arg("--help").output().unwrap();
|
||||
assert!(String::from_utf8_lossy(&output.stdout).contains("--max-file-size"));
|
||||
for size in ["17GB", "2", "lots"] {
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_solidcraft-cli")).args(["--max-file-size", size, "exec", "file.new"]).output().unwrap();
|
||||
assert!(!output.status.success(), "{size} was accepted");
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
assert!(stderr.starts_with("error: --max-file-size"), "{size}: {stderr}");
|
||||
}
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_solidcraft-cli")).args(["exec", "file.new", "--max-file-size=2GB"]).output().unwrap();
|
||||
assert!(output.status.success(), "{}", String::from_utf8_lossy(&output.stderr));
|
||||
|
||||
// A sparse design file just over the default 256 MB: refused unread, then read with the flag
|
||||
// (and refused for what it holds, which is no design).
|
||||
let dir = std::env::temp_dir().join(format!("solidcraft-cli-4086-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let path = dir.join("big.solidcraft");
|
||||
std::fs::File::create(&path).unwrap().set_len((256 << 20) + 1).unwrap();
|
||||
let path = path.to_string_lossy().to_string();
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_solidcraft-cli")).args(["eval", &path]).output().unwrap();
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
assert!(!output.status.success() && stderr.contains("too large") && stderr.contains("--max-file-size"), "{stderr}");
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_solidcraft-cli")).args(["--max-file-size", "1GB", "eval", &path]).output().unwrap();
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
assert!(!output.status.success() && !stderr.contains("too large"), "{stderr}");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
@@ -761,12 +761,15 @@ fn main() -> eframe::Result {
|
||||
let mut sample = false;
|
||||
// `--theme-file PATH`: follow that theme file for this run without saving it (#7573).
|
||||
let mut theme_file: Option<String> = None;
|
||||
let mut max_file_size = None;
|
||||
let mut args = std::env::args().skip(1);
|
||||
while let Some(a) = args.next() {
|
||||
match a.as_str() {
|
||||
"--control" => control_port = args.next().and_then(|p| p.parse().ok()),
|
||||
"--sample" => sample = true,
|
||||
"--theme-file" => theme_file = args.next(),
|
||||
"--max-file-size" => max_file_size = Some(args.next()),
|
||||
s if s.starts_with("--max-file-size=") => max_file_size = Some(s.strip_prefix("--max-file-size=").map(str::to_string)),
|
||||
"--safe-mode" => safe_mode = true,
|
||||
"--version" | "-V" => {
|
||||
println!("solidcraft {}", env!("CARGO_PKG_VERSION"));
|
||||
@@ -787,13 +790,21 @@ fn main() -> eframe::Result {
|
||||
}
|
||||
"--help" | "-h" => {
|
||||
println!(
|
||||
"usage: solidcraft [--control PORT] [--sample] [--theme-file THEME.json] [--crash-log] [--safe-mode] [design.sc | part.step]"
|
||||
"usage: solidcraft [--control PORT] [--sample] [--theme-file THEME.json] [--crash-log] [--safe-mode] [--max-file-size SIZE] [design.sc | part.step]"
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
_ => files.push(a),
|
||||
}
|
||||
}
|
||||
// `--max-file-size 2GB`: the largest files this run reads, over Preferences, never saved (#4086).
|
||||
if let Some(value) = max_file_size {
|
||||
let applied = startup::max_file_size(value.as_deref()).and_then(|bytes| solidcraft_engine::io::limits::set_override(Some(bytes)));
|
||||
if let Err(error) = applied {
|
||||
eprintln!("SolidCraft: {error}");
|
||||
return Err(eframe::Error::AppCreation(std::io::Error::other(error).into()));
|
||||
}
|
||||
}
|
||||
// Settings that don't read are moved aside; launches that never got a window are counted,
|
||||
// and after a few in a row this one starts in safe mode (docs/book/src/guide/troubleshooting.md).
|
||||
let mut notes: Vec<String> = Vec::new();
|
||||
|
||||
@@ -302,6 +302,14 @@ pub fn system_title_bar(windows: bool, backends: eframe::wgpu::Backends) -> bool
|
||||
windows && backends.contains(Backends::GL) && !backends.intersects(Backends::DX12 | Backends::VULKAN)
|
||||
}
|
||||
|
||||
/// The `--max-file-size` value (#4086): a size such as `2GB` or `1500MB`, at most 16 GB. It raises
|
||||
/// the largest STEP/import and design file this run reads, over the saved preference, without
|
||||
/// saving anything. A missing or bad value stops the start with this error.
|
||||
pub fn max_file_size(value: Option<&str>) -> Result<u64, String> {
|
||||
let value = value.ok_or("--max-file-size needs a size, for example --max-file-size 2GB")?;
|
||||
solidcraft_engine::io::limits::parse_flag(value).map_err(|e| format!("--max-file-size: {e}"))
|
||||
}
|
||||
|
||||
/// The message shown when no window could be opened at all.
|
||||
pub fn no_window_message(error: &str, settings: Option<&Path>) -> String {
|
||||
let folder = settings.map(|d| d.display().to_string()).unwrap_or_else(|| "the SolidCraft settings folder".into());
|
||||
@@ -324,6 +332,16 @@ mod tests {
|
||||
["Integrated", "Discrete small", "Discrete large"].into_iter().map(|name| AdapterChoice { name: name.into(), compatible: true }).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn max_file_size_parses_sizes_and_refuses_bad_ones() {
|
||||
assert_eq!(max_file_size(Some("2GB")), Ok(2 << 30));
|
||||
assert_eq!(max_file_size(Some("1500MB")), Ok(1500 << 20));
|
||||
for bad in [None, Some(""), Some("2"), Some("17GB"), Some("lots"), Some("-1GB")] {
|
||||
let error = max_file_size(bad).unwrap_err();
|
||||
assert!(error.contains("--max-file-size"), "{bad:?}: {error}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn adapter_names_environment_override_and_missing_card_fallback() {
|
||||
let cards = cards();
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
{
|
||||
"en": {
|
||||
"prefs.max_file_size": "Largest file to open",
|
||||
"prefs.max_file_size_design": "Design files",
|
||||
"prefs.max_file_size_flag": "This run started with --max-file-size {size}, which applies until SolidCraft closes. These settings apply when it starts without it.",
|
||||
"prefs.max_file_size_note": "Defaults: 512 MB and 256 MB; at most 16 GB. Opening a file takes several times its size in memory. A design that keeps a large import may need a higher design file limit to save and reopen.",
|
||||
"prefs.max_file_size_step": "STEP and import files",
|
||||
"prefs.max_file_size_web": "The web app opens STEP and import files up to 512 MB and designs up to 256 MB: a browser tab can't hold larger files. The desktop app can raise these limits.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"ar": {
|
||||
"prefs.max_file_size": "أكبر ملف يمكن فتحه",
|
||||
"prefs.max_file_size_design": "ملفات التصميم",
|
||||
"prefs.max_file_size_flag": "بدأ هذا التشغيل بالخيار --max-file-size {size}، ويسري حتى إغلاق SolidCraft. تسري هذه الإعدادات عند تشغيله دون هذا الخيار.",
|
||||
"prefs.max_file_size_note": "القيم الافتراضية: 512 MB و256 MB؛ الحد الأقصى 16 GB. يتطلب فتح ملف ذاكرة تعادل حجمه عدة مرات. قد يحتاج التصميم الذي يحتفظ باستيراد كبير إلى حد أعلى لملف التصميم لحفظه وإعادة فتحه.",
|
||||
"prefs.max_file_size_step": "ملفات STEP والاستيراد",
|
||||
"prefs.max_file_size_web": "يفتح تطبيق الويب ملفات STEP والاستيراد حتى 512 MB والتصاميم حتى 256 MB؛ لا يتسع تبويب المتصفح لملفات أكبر. يمكن رفع هذه الحدود في تطبيق سطح المكتب.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"cs": {
|
||||
"prefs.max_file_size": "Největší soubor k otevření",
|
||||
"prefs.max_file_size_design": "Soubory návrhů",
|
||||
"prefs.max_file_size_flag": "Toto spuštění používá --max-file-size {size} až do zavření SolidCraft. Tato nastavení platí při spuštění bez této volby.",
|
||||
"prefs.max_file_size_note": "Výchozí: 512 MB a 256 MB; nejvýše 16 GB. Otevření souboru vyžaduje několikanásobek jeho velikosti v paměti. Návrh s velkým importem může pro uložení a opětovné otevření potřebovat vyšší limit souboru návrhu.",
|
||||
"prefs.max_file_size_step": "Soubory STEP a importu",
|
||||
"prefs.max_file_size_web": "Webová aplikace otevírá soubory STEP a importu do 512 MB a návrhy do 256 MB: karta prohlížeče větší soubory nepojme. V aplikaci pro počítač lze limity zvýšit.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"da": {
|
||||
"prefs.max_file_size": "Største fil, der kan åbnes",
|
||||
"prefs.max_file_size_design": "Designfiler",
|
||||
"prefs.max_file_size_flag": "Denne kørsel blev startet med --max-file-size {size}, som gælder, indtil SolidCraft lukkes. Disse indstillinger gælder ved start uden denne valgmulighed.",
|
||||
"prefs.max_file_size_note": "Standard: 512 MB og 256 MB; højst 16 GB. Åbning af en fil kræver flere gange dens størrelse i hukommelse. Et design med en stor import kan kræve en højere grænse for designfiler for at kunne gemmes og åbnes igen.",
|
||||
"prefs.max_file_size_step": "STEP- og importfiler",
|
||||
"prefs.max_file_size_web": "Webappen åbner STEP- og importfiler op til 512 MB og design op til 256 MB: en browserfane kan ikke rumme større filer. Grænserne kan hæves i skrivebordsappen.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"de": {
|
||||
"prefs.max_file_size": "Maximale Dateigröße zum Öffnen",
|
||||
"prefs.max_file_size_design": "Designdateien",
|
||||
"prefs.max_file_size_flag": "Dieser Lauf wurde mit --max-file-size {size} gestartet. Der Wert gilt, bis SolidCraft geschlossen wird. Diese Einstellungen gelten beim Start ohne diese Option.",
|
||||
"prefs.max_file_size_note": "Standard: 512 MB und 256 MB; höchstens 16 GB. Das Öffnen einer Datei benötigt ein Mehrfaches ihrer Größe im Arbeitsspeicher. Ein Design mit großem Import benötigt zum Speichern und erneuten Öffnen eventuell eine höhere Grenze für Designdateien.",
|
||||
"prefs.max_file_size_step": "STEP- und Importdateien",
|
||||
"prefs.max_file_size_web": "Die Web-App öffnet STEP- und Importdateien bis 512 MB und Designs bis 256 MB: Ein Browser-Tab kann keine größeren Dateien aufnehmen. In der Desktop-App lassen sich diese Grenzen erhöhen.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"es": {
|
||||
"prefs.max_file_size": "Tamaño máximo de archivo al abrir",
|
||||
"prefs.max_file_size_design": "Archivos de diseño",
|
||||
"prefs.max_file_size_flag": "Esta ejecución se inició con --max-file-size {size}, que se aplica hasta cerrar SolidCraft. Estos ajustes se aplican al iniciar sin esa opción.",
|
||||
"prefs.max_file_size_note": "Valores predeterminados: 512 MB y 256 MB; máximo 16 GB. Abrir un archivo requiere varias veces su tamaño en memoria. Un diseño que conserva una importación grande puede necesitar un límite mayor para guardarse y volver a abrirse.",
|
||||
"prefs.max_file_size_step": "Archivos STEP y de importación",
|
||||
"prefs.max_file_size_web": "La aplicación web abre archivos STEP y de importación de hasta 512 MB y diseños de hasta 256 MB: una pestaña del navegador no admite archivos mayores. La aplicación de escritorio permite aumentar estos límites.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"fr": {
|
||||
"prefs.max_file_size": "Taille maximale à ouvrir",
|
||||
"prefs.max_file_size_design": "Fichiers de conception",
|
||||
"prefs.max_file_size_flag": "Ce lancement utilise --max-file-size {size} jusqu’à la fermeture de SolidCraft. Ces réglages s’appliquent au lancement sans cette option.",
|
||||
"prefs.max_file_size_note": "Valeurs par défaut : 512 Mo et 256 Mo ; maximum 16 Go. Ouvrir un fichier exige plusieurs fois sa taille en mémoire. Une conception conservant une importation volumineuse peut nécessiter une limite supérieure pour être enregistrée et rouverte.",
|
||||
"prefs.max_file_size_step": "Fichiers STEP et d’importation",
|
||||
"prefs.max_file_size_web": "L’application web ouvre les fichiers STEP et d’importation jusqu’à 512 Mo et les conceptions jusqu’à 256 Mo : un onglet du navigateur ne peut pas contenir de fichiers plus volumineux. L’application de bureau permet de relever ces limites.",
|
||||
"prefs.megabytes": "Mo"
|
||||
},
|
||||
"gl": {
|
||||
"prefs.max_file_size": "Tamaño máximo de ficheiro ao abrir",
|
||||
"prefs.max_file_size_design": "Ficheiros de deseño",
|
||||
"prefs.max_file_size_flag": "Esta execución iniciouse con --max-file-size {size}, que se aplica ata pechar SolidCraft. Estes axustes aplícanse ao iniciar sen esa opción.",
|
||||
"prefs.max_file_size_note": "Valores predeterminados: 512 MB e 256 MB; máximo 16 GB. Abrir un ficheiro require varias veces o seu tamaño en memoria. Un deseño que conserva unha importación grande pode precisar un límite maior para gardarse e abrirse de novo.",
|
||||
"prefs.max_file_size_step": "Ficheiros STEP e de importación",
|
||||
"prefs.max_file_size_web": "A aplicación web abre ficheiros STEP e de importación de ata 512 MB e deseños de ata 256 MB: unha lapela do navegador non admite ficheiros maiores. A aplicación de escritorio permite aumentar estes límites.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"he": {
|
||||
"prefs.max_file_size": "גודל קובץ מרבי לפתיחה",
|
||||
"prefs.max_file_size_design": "קובצי תכן",
|
||||
"prefs.max_file_size_flag": "ההפעלה הנוכחית החלה עם --max-file-size {size}, שחל עד סגירת SolidCraft. הגדרות אלה חלות בהפעלה ללא אפשרות זו.",
|
||||
"prefs.max_file_size_note": "ברירות מחדל: 512 MB ו־256 MB; לכל היותר 16 GB. פתיחת קובץ דורשת זיכרון בנפח גדול פי כמה מגודלו. תכן ששומר ייבוא גדול עשוי לדרוש מגבלה גבוהה יותר לקובצי תכן כדי לשמור ולפתוח אותו מחדש.",
|
||||
"prefs.max_file_size_step": "קובצי STEP וייבוא",
|
||||
"prefs.max_file_size_web": "יישום הדפדפן פותח קובצי STEP וייבוא עד 512 MB וקובצי תכן עד 256 MB: לשונית דפדפן אינה יכולה להכיל קבצים גדולים יותר. ביישום למחשב ניתן להעלות מגבלות אלה.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"hu": {
|
||||
"prefs.max_file_size": "Megnyitható fájl legnagyobb mérete",
|
||||
"prefs.max_file_size_design": "Tervfájlok",
|
||||
"prefs.max_file_size_flag": "Ez a futtatás a --max-file-size {size} kapcsolóval indult, amely a SolidCraft bezárásáig érvényes. Ezek a beállítások a kapcsoló nélküli indításkor érvényesek.",
|
||||
"prefs.max_file_size_note": "Alapértékek: 512 MB és 256 MB; legfeljebb 16 GB. Egy fájl megnyitásához a mérete többszörösének megfelelő memória kell. Nagy importot tároló terv mentéséhez és újbóli megnyitásához magasabb tervfájlkorlát lehet szükséges.",
|
||||
"prefs.max_file_size_step": "STEP- és importfájlok",
|
||||
"prefs.max_file_size_web": "A webalkalmazás legfeljebb 512 MB-os STEP- és importfájlokat, valamint 256 MB-os terveket nyit meg: egy böngészőlap nem tud nagyobb fájlokat tárolni. Az asztali alkalmazásban e korlátok növelhetők.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"id": {
|
||||
"prefs.max_file_size": "Ukuran file maksimum untuk dibuka",
|
||||
"prefs.max_file_size_design": "File desain",
|
||||
"prefs.max_file_size_flag": "Sesi ini dimulai dengan --max-file-size {size}, yang berlaku hingga SolidCraft ditutup. Pengaturan ini berlaku saat dimulai tanpa opsi tersebut.",
|
||||
"prefs.max_file_size_note": "Bawaan: 512 MB dan 256 MB; maksimum 16 GB. Membuka file memerlukan memori beberapa kali ukurannya. Desain yang menyimpan impor besar mungkin memerlukan batas file desain lebih tinggi agar dapat disimpan dan dibuka kembali.",
|
||||
"prefs.max_file_size_step": "File STEP dan impor",
|
||||
"prefs.max_file_size_web": "Aplikasi web membuka file STEP dan impor hingga 512 MB serta desain hingga 256 MB: tab peramban tidak dapat menampung file yang lebih besar. Aplikasi desktop dapat menaikkan batas ini.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"it": {
|
||||
"prefs.max_file_size": "Dimensione massima dei file da aprire",
|
||||
"prefs.max_file_size_design": "File di progettazione",
|
||||
"prefs.max_file_size_flag": "Questo avvio usa --max-file-size {size}, valido fino alla chiusura di SolidCraft. Queste impostazioni si applicano all’avvio senza tale opzione.",
|
||||
"prefs.max_file_size_note": "Valori predefiniti: 512 MB e 256 MB; massimo 16 GB. Aprire un file richiede memoria pari a più volte la sua dimensione. Un progetto che conserva un’importazione grande può richiedere un limite maggiore per essere salvato e riaperto.",
|
||||
"prefs.max_file_size_step": "File STEP e di importazione",
|
||||
"prefs.max_file_size_web": "L’app web apre file STEP e di importazione fino a 512 MB e progetti fino a 256 MB: una scheda del browser non può contenere file più grandi. L’app desktop permette di aumentare questi limiti.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"ja": {
|
||||
"prefs.max_file_size": "開けるファイルの最大サイズ",
|
||||
"prefs.max_file_size_design": "デザインファイル",
|
||||
"prefs.max_file_size_flag": "今回は --max-file-size {size} を指定して起動したため、SolidCraft を閉じるまでその値が適用されます。この設定は、そのオプションなしで起動したときに適用されます。",
|
||||
"prefs.max_file_size_note": "既定値は 512 MB と 256 MB、上限は 16 GB です。ファイルを開くには、サイズの数倍のメモリが必要です。大きなインポートを保持するデザインの保存と再読み込みには、デザインファイルの上限を上げる必要がある場合があります。",
|
||||
"prefs.max_file_size_step": "STEP・インポートファイル",
|
||||
"prefs.max_file_size_web": "ウェブ版で開けるのは STEP・インポートファイルが 512 MB、デザインが 256 MB までです。ブラウザーのタブはそれ以上のファイルを保持できません。デスクトップ版では上限を上げられます。",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"ko": {
|
||||
"prefs.max_file_size": "열 수 있는 최대 파일 크기",
|
||||
"prefs.max_file_size_design": "디자인 파일",
|
||||
"prefs.max_file_size_flag": "이번 실행은 --max-file-size {size}로 시작했으며 SolidCraft를 닫을 때까지 적용됩니다. 이 설정은 해당 옵션 없이 시작할 때 적용됩니다.",
|
||||
"prefs.max_file_size_note": "기본값: 512 MB 및 256 MB, 최대 16 GB. 파일을 열려면 파일 크기의 몇 배에 달하는 메모리가 필요합니다. 큰 가져오기 데이터를 보관하는 디자인은 저장하고 다시 열기 위해 디자인 파일 한도를 높여야 할 수 있습니다.",
|
||||
"prefs.max_file_size_step": "STEP 및 가져오기 파일",
|
||||
"prefs.max_file_size_web": "웹 앱은 STEP 및 가져오기 파일을 512 MB까지, 디자인을 256 MB까지 엽니다. 브라우저 탭은 더 큰 파일을 담을 수 없습니다. 데스크톱 앱에서는 이 한도를 높일 수 있습니다.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"ms": {
|
||||
"prefs.max_file_size": "Saiz fail maksimum untuk dibuka",
|
||||
"prefs.max_file_size_design": "Fail reka bentuk",
|
||||
"prefs.max_file_size_flag": "Pelaksanaan ini bermula dengan --max-file-size {size}, yang terpakai sehingga SolidCraft ditutup. Tetapan ini terpakai apabila dimulakan tanpa pilihan itu.",
|
||||
"prefs.max_file_size_note": "Lalai: 512 MB dan 256 MB; maksimum 16 GB. Membuka fail memerlukan memori beberapa kali saiznya. Reka bentuk yang menyimpan import besar mungkin memerlukan had fail reka bentuk lebih tinggi untuk disimpan dan dibuka semula.",
|
||||
"prefs.max_file_size_step": "Fail STEP dan import",
|
||||
"prefs.max_file_size_web": "Aplikasi web membuka fail STEP dan import sehingga 512 MB serta reka bentuk sehingga 256 MB: tab pelayar tidak dapat memuatkan fail lebih besar. Aplikasi desktop boleh menaikkan had ini.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"nb": {
|
||||
"prefs.max_file_size": "Største fil som kan åpnes",
|
||||
"prefs.max_file_size_design": "Designfiler",
|
||||
"prefs.max_file_size_flag": "Denne kjøringen startet med --max-file-size {size}, som gjelder til SolidCraft lukkes. Disse innstillingene gjelder ved oppstart uten dette valget.",
|
||||
"prefs.max_file_size_note": "Standard: 512 MB og 256 MB; høyst 16 GB. Å åpne en fil krever flere ganger filstørrelsen i minne. Et design med en stor import kan trenge en høyere grense for designfiler for å kunne lagres og åpnes igjen.",
|
||||
"prefs.max_file_size_step": "STEP- og importfiler",
|
||||
"prefs.max_file_size_web": "Nettappen åpner STEP- og importfiler opptil 512 MB og design opptil 256 MB: en nettleserfane kan ikke romme større filer. Grensene kan økes i skrivebordsappen.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"nl": {
|
||||
"prefs.max_file_size": "Maximale bestandsgrootte om te openen",
|
||||
"prefs.max_file_size_design": "Ontwerpbestanden",
|
||||
"prefs.max_file_size_flag": "Deze uitvoering is gestart met --max-file-size {size}, dat geldt totdat SolidCraft sluit. Deze instellingen gelden bij het starten zonder die optie.",
|
||||
"prefs.max_file_size_note": "Standaard: 512 MB en 256 MB; maximaal 16 GB. Een bestand openen vereist meerdere keren de bestandsgrootte aan geheugen. Een ontwerp met een grote import kan een hogere limiet voor ontwerpbestanden nodig hebben om te worden opgeslagen en heropend.",
|
||||
"prefs.max_file_size_step": "STEP- en importbestanden",
|
||||
"prefs.max_file_size_web": "De webapp opent STEP- en importbestanden tot 512 MB en ontwerpen tot 256 MB: een browsertabblad kan geen grotere bestanden bevatten. In de desktopapp kunnen deze limieten worden verhoogd.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"pl": {
|
||||
"prefs.max_file_size": "Maksymalny rozmiar otwieranego pliku",
|
||||
"prefs.max_file_size_design": "Pliki projektów",
|
||||
"prefs.max_file_size_flag": "To uruchomienie używa --max-file-size {size} aż do zamknięcia SolidCraft. Te ustawienia obowiązują przy uruchomieniu bez tej opcji.",
|
||||
"prefs.max_file_size_note": "Domyślnie: 512 MB i 256 MB; maksymalnie 16 GB. Otwarcie pliku wymaga pamięci kilkakrotnie większej od jego rozmiaru. Projekt z dużym importem może wymagać wyższego limitu pliku projektu, aby go zapisać i ponownie otworzyć.",
|
||||
"prefs.max_file_size_step": "Pliki STEP i importu",
|
||||
"prefs.max_file_size_web": "Aplikacja internetowa otwiera pliki STEP i importu do 512 MB oraz projekty do 256 MB: karta przeglądarki nie pomieści większych plików. W aplikacji komputerowej można zwiększyć te limity.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"pt-BR": {
|
||||
"prefs.max_file_size": "Tamanho máximo de arquivo a abrir",
|
||||
"prefs.max_file_size_design": "Arquivos de projeto",
|
||||
"prefs.max_file_size_flag": "Esta execução foi iniciada com --max-file-size {size}, que vale até fechar o SolidCraft. Estas configurações se aplicam ao iniciar sem essa opção.",
|
||||
"prefs.max_file_size_note": "Padrões: 512 MB e 256 MB; máximo de 16 GB. Abrir um arquivo exige várias vezes seu tamanho em memória. Um projeto que mantém uma importação grande pode precisar de um limite maior para ser salvo e reaberto.",
|
||||
"prefs.max_file_size_step": "Arquivos STEP e de importação",
|
||||
"prefs.max_file_size_web": "O aplicativo web abre arquivos STEP e de importação de até 512 MB e projetos de até 256 MB: uma aba do navegador não comporta arquivos maiores. O aplicativo para desktop permite aumentar esses limites.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"ro": {
|
||||
"prefs.max_file_size": "Dimensiunea maximă a fișierului de deschis",
|
||||
"prefs.max_file_size_design": "Fișiere de proiect",
|
||||
"prefs.max_file_size_flag": "Această rulare a pornit cu --max-file-size {size}, valabil până la închiderea SolidCraft. Aceste setări se aplică la pornirea fără această opțiune.",
|
||||
"prefs.max_file_size_note": "Valori implicite: 512 MB și 256 MB; maximum 16 GB. Deschiderea unui fișier necesită memorie de câteva ori mai mare decât dimensiunea sa. Un proiect care păstrează un import mare poate necesita o limită mai mare pentru a fi salvat și redeschis.",
|
||||
"prefs.max_file_size_step": "Fișiere STEP și de import",
|
||||
"prefs.max_file_size_web": "Aplicația web deschide fișiere STEP și de import de până la 512 MB și proiecte de până la 256 MB: o filă de browser nu poate conține fișiere mai mari. Aplicația desktop permite creșterea acestor limite.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"ru": {
|
||||
"prefs.max_file_size": "Максимальный размер открываемого файла",
|
||||
"prefs.max_file_size_design": "Файлы дизайна",
|
||||
"prefs.max_file_size_flag": "Этот запуск использует --max-file-size {size} до закрытия SolidCraft. Эти настройки действуют при запуске без этого параметра.",
|
||||
"prefs.max_file_size_note": "По умолчанию: 512 МБ и 256 МБ; максимум 16 ГБ. Для открытия файла нужно в несколько раз больше памяти, чем его размер. Дизайну с большим импортом может потребоваться больший предел размера файла дизайна для сохранения и повторного открытия.",
|
||||
"prefs.max_file_size_step": "Файлы STEP и импорта",
|
||||
"prefs.max_file_size_web": "Веб-приложение открывает файлы STEP и импорта до 512 МБ и дизайны до 256 МБ: вкладка браузера не вмещает более крупные файлы. В настольном приложении эти пределы можно увеличить.",
|
||||
"prefs.megabytes": "МБ"
|
||||
},
|
||||
"sv": {
|
||||
"prefs.max_file_size": "Största fil som kan öppnas",
|
||||
"prefs.max_file_size_design": "Konstruktionsfiler",
|
||||
"prefs.max_file_size_flag": "Denna körning startades med --max-file-size {size}, som gäller tills SolidCraft stängs. Dessa inställningar gäller vid start utan det alternativet.",
|
||||
"prefs.max_file_size_note": "Standard: 512 MB och 256 MB; högst 16 GB. Att öppna en fil kräver flera gånger dess storlek i minne. En konstruktion med en stor import kan behöva en högre gräns för konstruktionsfiler för att kunna sparas och öppnas igen.",
|
||||
"prefs.max_file_size_step": "STEP- och importfiler",
|
||||
"prefs.max_file_size_web": "Webbappen öppnar STEP- och importfiler upp till 512 MB och konstruktioner upp till 256 MB: en webbläsarflik kan inte rymma större filer. Gränserna kan höjas i skrivbordsappen.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"tr": {
|
||||
"prefs.max_file_size": "Açılabilecek en büyük dosya",
|
||||
"prefs.max_file_size_design": "Tasarım dosyaları",
|
||||
"prefs.max_file_size_flag": "Bu çalıştırma --max-file-size {size} ile başlatıldı; SolidCraft kapanana kadar geçerlidir. Bu ayarlar, bu seçenek olmadan başlatıldığında uygulanır.",
|
||||
"prefs.max_file_size_note": "Varsayılanlar: 512 MB ve 256 MB; en fazla 16 GB. Dosya açmak, boyutunun birkaç katı bellek gerektirir. Büyük bir içe aktarımı tutan tasarımın kaydedilip yeniden açılması için daha yüksek bir tasarım dosyası sınırı gerekebilir.",
|
||||
"prefs.max_file_size_step": "STEP ve içe aktarma dosyaları",
|
||||
"prefs.max_file_size_web": "Web uygulaması 512 MB’a kadar STEP ve içe aktarma dosyalarını, 256 MB’a kadar tasarımları açar: tarayıcı sekmesi daha büyük dosyaları barındıramaz. Masaüstü uygulamasında bu sınırlar artırılabilir.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"uk": {
|
||||
"prefs.max_file_size": "Найбільший файл для відкриття",
|
||||
"prefs.max_file_size_design": "Файли проєктів",
|
||||
"prefs.max_file_size_flag": "Цей запуск використовує --max-file-size {size} до закриття SolidCraft. Ці налаштування діють під час запуску без цього параметра.",
|
||||
"prefs.max_file_size_note": "Типово: 512 МБ і 256 МБ; щонайбільше 16 ГБ. Для відкриття файлу потрібно в кілька разів більше пам’яті, ніж його розмір. Проєкт із великим імпортом може потребувати вищої межі розміру файлу проєкту для збереження й повторного відкриття.",
|
||||
"prefs.max_file_size_step": "Файли STEP та імпорту",
|
||||
"prefs.max_file_size_web": "Вебзастосунок відкриває файли STEP та імпорту до 512 МБ і проєкти до 256 МБ: вкладка браузера не вміщує більші файли. У настільному застосунку ці межі можна збільшити.",
|
||||
"prefs.megabytes": "МБ"
|
||||
},
|
||||
"vi": {
|
||||
"prefs.max_file_size": "Kích thước tệp tối đa để mở",
|
||||
"prefs.max_file_size_design": "Tệp thiết kế",
|
||||
"prefs.max_file_size_flag": "Lần chạy này bắt đầu với --max-file-size {size}, có hiệu lực đến khi đóng SolidCraft. Các cài đặt này áp dụng khi khởi động không có tùy chọn đó.",
|
||||
"prefs.max_file_size_note": "Mặc định: 512 MB và 256 MB; tối đa 16 GB. Mở tệp cần lượng bộ nhớ gấp nhiều lần kích thước tệp. Thiết kế giữ dữ liệu nhập lớn có thể cần giới hạn tệp thiết kế cao hơn để lưu và mở lại.",
|
||||
"prefs.max_file_size_step": "Tệp STEP và tệp nhập",
|
||||
"prefs.max_file_size_web": "Ứng dụng web mở tệp STEP và tệp nhập tối đa 512 MB, thiết kế tối đa 256 MB: thẻ trình duyệt không chứa được tệp lớn hơn. Ứng dụng máy tính cho phép tăng các giới hạn này.",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"zh": {
|
||||
"prefs.max_file_size": "可打开的最大文件",
|
||||
"prefs.max_file_size_design": "设计文件",
|
||||
"prefs.max_file_size_flag": "本次启动指定了 --max-file-size {size},该值在关闭 SolidCraft 前有效。不带此选项启动时才会应用这些设置。",
|
||||
"prefs.max_file_size_note": "默认值:512 MB 和 256 MB;上限为 16 GB。打开文件需要数倍于文件大小的内存。保留大型导入数据的设计可能需要提高设计文件上限,才能保存并重新打开。",
|
||||
"prefs.max_file_size_step": "STEP 和导入文件",
|
||||
"prefs.max_file_size_web": "网页版可打开最大 512 MB 的 STEP 和导入文件,以及最大 256 MB 的设计:浏览器标签页无法容纳更大的文件。桌面版可提高这些上限。",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"zh-TW": {
|
||||
"prefs.max_file_size": "可開啟的最大檔案",
|
||||
"prefs.max_file_size_design": "設計檔案",
|
||||
"prefs.max_file_size_flag": "本次啟動指定了 --max-file-size {size},此值在關閉 SolidCraft 前有效。不帶此選項啟動時才會套用這些設定。",
|
||||
"prefs.max_file_size_note": "預設值:512 MB 和 256 MB;上限為 16 GB。開啟檔案需要數倍於檔案大小的記憶體。保留大型匯入資料的設計可能需要提高設計檔案上限,才能儲存並重新開啟。",
|
||||
"prefs.max_file_size_step": "STEP 和匯入檔案",
|
||||
"prefs.max_file_size_web": "網頁版可開啟最大 512 MB 的 STEP 和匯入檔案,以及最大 256 MB 的設計:瀏覽器分頁無法容納更大的檔案。桌面版可提高這些上限。",
|
||||
"prefs.megabytes": "MB"
|
||||
},
|
||||
"en-GB": {
|
||||
"prefs.max_file_size": "Largest file to open",
|
||||
"prefs.max_file_size_design": "Design files",
|
||||
"prefs.max_file_size_flag": "This run started with --max-file-size {size}, which applies until SolidCraft closes. These settings apply when it starts without it.",
|
||||
"prefs.max_file_size_note": "Defaults: 512 MB and 256 MB; at most 16 GB. Opening a file takes several times its size in memory. A design that keeps a large import may need a higher design file limit to save and reopen.",
|
||||
"prefs.max_file_size_step": "STEP and import files",
|
||||
"prefs.max_file_size_web": "The web app opens STEP and import files up to 512 MB and designs up to 256 MB: a browser tab can't hold larger files. The desktop app can raise these limits.",
|
||||
"prefs.megabytes": "MB"
|
||||
}
|
||||
}
|
||||
@@ -163,8 +163,9 @@ fn read_link(file: &Path, own: Option<&str>) -> Result<Vec<u8>> {
|
||||
}
|
||||
// A network location only when its server is allowed, a device never: judged from the text
|
||||
// before anything is read (on Windows, reading `\\host\share\x` connects to the host).
|
||||
solidcraft_io::vfs::read_design_path(&shown, own, solidcraft_io::MAX_DESIGN_BYTES).map_err(|e| {
|
||||
let e = e.to_string();
|
||||
let design = solidcraft_io::limits::Kind::Design;
|
||||
solidcraft_io::vfs::read_design_path(&shown, own, solidcraft_io::limits::max_design_bytes()).map_err(|e| {
|
||||
let e = solidcraft_io::limits::explain(design, e).to_string();
|
||||
EngineError::Other(if e.starts_with(&shown) { e } else { format!("{shown}: {e}") })
|
||||
})
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ fn step_options(p: &Value, cmd: &str) -> Result<StepOptions> {
|
||||
|
||||
/// Read a STEP file as an Import feature.
|
||||
fn read_step(path: &str, names: solidcraft_io::StepNames) -> Result<solidcraft_io::StepFeature> {
|
||||
let bytes = solidcraft_io::vfs::read(path, solidcraft_io::MAX_STEP_BYTES).map_err(|e| EngineError::Other(format!("{path}: {e}")))?;
|
||||
let bytes = solidcraft_io::limits::read(path, solidcraft_io::limits::Kind::Step).map_err(|e| EngineError::Other(format!("{path}: {e}")))?;
|
||||
solidcraft_io::step_import_feature_named(&bytes, path, names).map_err(|e| EngineError::Other(format!("{path}: {e}")))
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ pub fn load(dir: &Path, id: &str) -> Result<(Document, Entry)> {
|
||||
}
|
||||
let entry = read_entry(&file(dir, id, "json")).filter(|e| e.id == id).ok_or_else(|| EngineError::Other(format!("no recovered design `{id}`")))?;
|
||||
let path = design_file(dir, id);
|
||||
let bytes = solidcraft_io::vfs::read(&path.to_string_lossy(), solidcraft_io::MAX_DESIGN_BYTES)
|
||||
let bytes = solidcraft_io::limits::read(&path.to_string_lossy(), solidcraft_io::limits::Kind::Design)
|
||||
.map_err(|e| EngineError::Other(format!("recovered design `{id}`: {e}")))?;
|
||||
Ok((solidcraft_io::read_design(&bytes)?, entry))
|
||||
}
|
||||
|
||||
@@ -112,3 +112,49 @@ fn a_cancelled_preview_import_leaves_no_failure_in_the_shared_cache() {
|
||||
assert!(result.error.is_none() && !result.skipped, "the design imports in full: {:?}", result.error);
|
||||
let _ = std::fs::remove_file(path);
|
||||
}
|
||||
|
||||
/// The largest files read (#4086). Over the default limits a STEP file and a design file are
|
||||
/// refused before anything is read, saying how to raise the limit; with the limits raised (the
|
||||
/// preference, or `--max-file-size` for one run, which wins) the same reads go ahead.
|
||||
#[test]
|
||||
fn raised_file_limits_let_larger_step_and_design_files_be_read() {
|
||||
use solidcraft_io::limits::{self, FileLimits, GB, Kind, MB};
|
||||
/// Puts the defaults back however the test ends.
|
||||
struct Defaults;
|
||||
impl Drop for Defaults {
|
||||
fn drop(&mut self) {
|
||||
let _ = limits::set_override(None);
|
||||
let _ = limits::set_preferred(FileLimits::DEFAULT);
|
||||
}
|
||||
}
|
||||
let _defaults = Defaults;
|
||||
let dir = std::env::temp_dir().join(format!("solidcraft-4086-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
// Sparse files: nothing is written, and a refusal reads nothing either.
|
||||
let sparse = |name: &str, len: u64| {
|
||||
let path = dir.join(name);
|
||||
std::fs::File::create(&path).unwrap().set_len(len).unwrap();
|
||||
path.to_string_lossy().to_string()
|
||||
};
|
||||
let step = sparse("big.step", 512 * MB + 1);
|
||||
let design = sparse("big.solidcraft", 256 * MB + 1);
|
||||
let mut s = Session::default();
|
||||
assert_eq!(limits::effective(), FileLimits::DEFAULT);
|
||||
for path in [&step, &design] {
|
||||
let error = s.execute("doc.open", &json!({"path": path})).unwrap_err().to_string();
|
||||
assert!(error.contains("too large") && error.contains("Largest file to open") && error.contains("--max-file-size"), "{error}");
|
||||
}
|
||||
// The preference raises both limits; the design is now read (and refused only for not being one).
|
||||
limits::set_preferred(FileLimits { step: GB, design: GB }).unwrap();
|
||||
assert_eq!((limits::max_step_bytes(), limits::max_design_bytes()), (1 << 30, 1 << 30));
|
||||
assert!(limits::check(Kind::Step, 512 * MB + 1).is_ok());
|
||||
let error = s.execute("doc.open", &json!({"path": design})).unwrap_err().to_string();
|
||||
assert!(!error.contains("too large"), "{error}");
|
||||
// The flag overrides the preference for the run, and the ceiling holds for both.
|
||||
limits::set_override(Some(2 * GB)).unwrap();
|
||||
assert_eq!(limits::effective(), FileLimits { step: 2 * GB, design: 2 * GB });
|
||||
assert!(limits::set_override(Some(16 * GB + 1)).is_err());
|
||||
assert!(limits::set_preferred(FileLimits { step: 17 * GB, design: GB }).is_err());
|
||||
assert_eq!(limits::preferred(), FileLimits { step: GB, design: GB }, "a refused value changes nothing");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
+79
-61
@@ -16,25 +16,37 @@ use serde_json::{Map, Value, json};
|
||||
use sha2::{Digest, Sha256};
|
||||
use solidcraft_doc::{Document, FeatureKind, MeshData};
|
||||
|
||||
use crate::{IoError, MAX_DESIGN_BYTES, Result, design_metadata::replace};
|
||||
use crate::{IoError, Result, design_metadata::replace};
|
||||
|
||||
const VERSION: &str = "solidcraft-container/1";
|
||||
const LEGACY_VERSION: &str = "solvecraft-container/1";
|
||||
const PREVIEW_VERSION: &str = "solidcraft-preview/1";
|
||||
const MAX_ENTRIES: usize = 10_000;
|
||||
/// The design file limit in force ([`crate::limits`]): the largest design file read or saved.
|
||||
fn max_design() -> usize {
|
||||
crate::limits::max_design_bytes()
|
||||
}
|
||||
/// An embedded STEP source may be as large as an import accepts. It is always stored
|
||||
/// Deflate-compressed, so the file itself stays within [`MAX_DESIGN_BYTES`] (#3221).
|
||||
const MAX_STEP_PART: usize = crate::MAX_STEP_BYTES;
|
||||
/// Deflate-compressed, so the file itself stays within the design file limit (#3221).
|
||||
fn max_step_part() -> usize {
|
||||
crate::limits::max_step_bytes()
|
||||
}
|
||||
/// Deflate level for STEP sources. Level 1 uses fixed Huffman codes: a 270 MiB STEP export
|
||||
/// shrank to 70 MB in 1.6 s, at level 2 to 47 MB in 3.1 s; higher levels gain little more.
|
||||
const STEP_LEVEL: i64 = 2;
|
||||
/// An embedded mesh may be as large as a STEP source. One bigger than the design file is
|
||||
/// stored Deflate-compressed, so a compressible large import can be saved (#6600). The file
|
||||
/// itself stays within [`MAX_DESIGN_BYTES`].
|
||||
const MAX_MESH_PART: usize = crate::MAX_STEP_BYTES;
|
||||
/// itself stays within the design file limit.
|
||||
fn max_mesh_part() -> usize {
|
||||
crate::limits::max_step_bytes()
|
||||
}
|
||||
/// Every other part is bounded by the file size limit.
|
||||
const MAX_PART: usize = MAX_DESIGN_BYTES;
|
||||
const MAX_EXPANDED: usize = MAX_STEP_PART + MAX_DESIGN_BYTES;
|
||||
fn max_part() -> usize {
|
||||
max_design()
|
||||
}
|
||||
fn max_expanded() -> usize {
|
||||
max_step_part().saturating_add(max_design())
|
||||
}
|
||||
const MESH_MAGIC: &[u8; 8] = b"SCMESH01";
|
||||
const MAX_PREVIEW_BYTES: usize = 8 << 20;
|
||||
const MAX_PREVIEW_TRIANGLES: usize = 100_000;
|
||||
@@ -81,11 +93,11 @@ struct PackageWriter {
|
||||
/// design file because they are stored compressed when they would not fit otherwise.
|
||||
fn part_limit(name: &str) -> usize {
|
||||
if name.ends_with(".step") {
|
||||
MAX_STEP_PART
|
||||
max_step_part()
|
||||
} else if name.ends_with(".mesh") {
|
||||
MAX_MESH_PART
|
||||
max_mesh_part()
|
||||
} else {
|
||||
MAX_PART
|
||||
max_part()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,14 +116,18 @@ impl PackageWriter {
|
||||
return Ok(());
|
||||
}
|
||||
self.expanded = self.expanded.checked_add(bytes.len()).ok_or_else(|| invalid("expanded size overflow"))?;
|
||||
if self.expanded > MAX_EXPANDED || self.names.len() > MAX_ENTRIES {
|
||||
if self.expanded > max_expanded() || self.names.len() > MAX_ENTRIES {
|
||||
return Err(invalid("package too large"));
|
||||
}
|
||||
let method = if compressed { zip::CompressionMethod::Deflated } else { zip::CompressionMethod::Stored };
|
||||
// A mesh past the file limit uses the STEP level: level 1 of a large payload leaves
|
||||
// more on disk, and this part exists only because compression is what makes it fit.
|
||||
let level = if name.ends_with(".step") || (name.ends_with(".mesh") && bytes.len() > MAX_PART) { STEP_LEVEL } else { 1 };
|
||||
let options = zip::write::SimpleFileOptions::default().compression_method(method).compression_level(compressed.then_some(level));
|
||||
let level = if name.ends_with(".step") || (name.ends_with(".mesh") && bytes.len() > max_part()) { STEP_LEVEL } else { 1 };
|
||||
// A part of 4 GiB or more (only with a raised file limit, #4086) needs a ZIP64 entry.
|
||||
let options = zip::write::SimpleFileOptions::default()
|
||||
.compression_method(method)
|
||||
.compression_level(compressed.then_some(level))
|
||||
.large_file(bytes.len() as u64 >= u64::from(u32::MAX));
|
||||
self.zip.start_file(name, options).map_err(invalid)?;
|
||||
self.zip.write_all(bytes).map_err(invalid)
|
||||
}
|
||||
@@ -128,11 +144,11 @@ impl PackageWriter {
|
||||
// The bytes written so far, plus what the open compressed part may still hold back.
|
||||
let written = self.zip.get_ref().map_or(usize::MAX, |c| c.get_ref().len()).saturating_add(1 << 20);
|
||||
let directory = self.names.len().saturating_add(entries).saturating_mul(256).saturating_add(65_536);
|
||||
budget.saturating_sub(written.saturating_add(directory)).min(MAX_EXPANDED.saturating_sub(self.expanded))
|
||||
budget.saturating_sub(written.saturating_add(directory)).min(max_expanded().saturating_sub(self.expanded))
|
||||
}
|
||||
fn blob(&mut self, bytes: &[u8], extension: &str, compressed: bool) -> Result<Value> {
|
||||
self.resolved =
|
||||
self.resolved.checked_add(bytes.len()).filter(|&n| n <= MAX_EXPANDED).ok_or_else(|| invalid("resolved payloads too large"))?;
|
||||
self.resolved.checked_add(bytes.len()).filter(|&n| n <= max_expanded()).ok_or_else(|| invalid("resolved payloads too large"))?;
|
||||
let name = format!("blobs/{}.{extension}", digest(bytes));
|
||||
self.part(&name, bytes, compressed)?;
|
||||
Ok(Value::String(name))
|
||||
@@ -176,25 +192,28 @@ const STEP_RESERVE: usize = 4 << 20;
|
||||
/// accepts, and, compressed as a save stores it, leave room in a design file for the rest of
|
||||
/// the design. Checked when the file is imported, so it never imports and then fails to save.
|
||||
pub fn check_step_storable(step: &str) -> Result<()> {
|
||||
let limit = MAX_DESIGN_BYTES - STEP_RESERVE;
|
||||
if step.len() > MAX_STEP_PART {
|
||||
return Err(IoError::Invalid(format!("STEP file too large ({} MB, limit {} MB)", step.len() >> 20, MAX_STEP_PART >> 20)));
|
||||
}
|
||||
let limit = max_design().saturating_sub(STEP_RESERVE);
|
||||
crate::limits::check(crate::limits::Kind::Step, step.len() as u64).map_err(|e| IoError::Invalid(format!("STEP {e}")))?;
|
||||
// Deflate adds at most a few bytes per 16 KiB block: smaller text always fits.
|
||||
if step.len() <= limit - (limit >> 10) {
|
||||
return Ok(());
|
||||
}
|
||||
let mut zip = zip::ZipWriter::new(Measure::default());
|
||||
let options = zip::write::SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated).compression_level(Some(STEP_LEVEL));
|
||||
let options = zip::write::SimpleFileOptions::default()
|
||||
.compression_method(zip::CompressionMethod::Deflated)
|
||||
.compression_level(Some(STEP_LEVEL))
|
||||
.large_file(step.len() as u64 >= u64::from(u32::MAX));
|
||||
zip.start_file("blobs/source.step", options).map_err(invalid)?;
|
||||
zip.write_all(step.as_bytes()).map_err(invalid)?;
|
||||
let compressed = usize::try_from(zip.finish().map_err(invalid)?.length).unwrap_or(usize::MAX);
|
||||
if compressed > limit {
|
||||
return Err(IoError::Invalid(format!(
|
||||
"STEP file too large to save in a design: {} MB of STEP text compresses to {} MB, over the {} MB a design file may hold",
|
||||
"STEP file too large to save in a design: {} MB of STEP text compresses to {} MB, over the {} MB a design file may hold. \
|
||||
The design file limit counts here too: {}",
|
||||
step.len() >> 20,
|
||||
compressed >> 20,
|
||||
limit >> 20
|
||||
limit >> 20,
|
||||
crate::limits::how_to_raise()
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
@@ -239,7 +258,7 @@ pub fn write_design_container_with_thumbnail(
|
||||
geometry: Option<&solidcraft_doc::SavedModel>,
|
||||
thumbnail: Option<&[u8]>,
|
||||
) -> Result<Vec<u8>> {
|
||||
write_container(doc, compression, preview, geometry, thumbnail, MAX_DESIGN_BYTES)
|
||||
write_container(doc, compression, preview, geometry, thumbnail, max_design())
|
||||
}
|
||||
|
||||
/// [`write_design_container_with_thumbnail`] within `budget` bytes for the optional caches (the
|
||||
@@ -269,7 +288,7 @@ fn write_container(
|
||||
let bytes = encode_mesh(mesh)?;
|
||||
// Fast saves store a mesh that fits. One past the file limit is deflated,
|
||||
// or it could never be saved (#6600). Compact deflates every mesh.
|
||||
let compress = compression == DesignCompression::Compact || bytes.len() > MAX_PART;
|
||||
let compress = compression == DesignCompression::Compact || bytes.len() > max_part();
|
||||
let blob = writer.blob(&bytes, "mesh", compress)?;
|
||||
let mut value = replace(mesh, fields([("positions", json!([])), ("triangles", json!([]))])).map_err(invalid)?;
|
||||
value.as_object_mut().ok_or_else(|| invalid("mesh metadata"))?.insert("mesh_blob".into(), blob);
|
||||
@@ -335,8 +354,13 @@ fn write_container(
|
||||
thumbnail::write(&mut writer, png, &metadata)?;
|
||||
}
|
||||
let bytes = writer.finish()?;
|
||||
if bytes.len() > MAX_DESIGN_BYTES {
|
||||
return Err(invalid(format!("the design would be {} MB, over the {} MB a design file may hold", bytes.len() >> 20, MAX_DESIGN_BYTES >> 20)));
|
||||
if bytes.len() > max_design() {
|
||||
return Err(invalid(format!(
|
||||
"the design would be {} MB, over the {} MB a design file may hold. {}",
|
||||
bytes.len() >> 20,
|
||||
max_design() >> 20,
|
||||
crate::limits::how_to_raise()
|
||||
)));
|
||||
}
|
||||
Ok(bytes)
|
||||
}
|
||||
@@ -352,13 +376,13 @@ fn validate_mesh(mesh: &MeshData) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Encoded blob length, or `None` when it would pass [`MAX_MESH_PART`] or overflow.
|
||||
/// Encoded blob length, or `None` when it would pass the mesh part limit or overflow.
|
||||
fn mesh_encoded_len(positions: usize, triangles: usize) -> Option<usize> {
|
||||
positions
|
||||
.checked_mul(8)
|
||||
.and_then(|v| triangles.checked_mul(4).and_then(|t| v.checked_add(t)))
|
||||
.and_then(|v| v.checked_add(24))
|
||||
.filter(|&n| n <= MAX_MESH_PART)
|
||||
.filter(|&n| n <= max_mesh_part())
|
||||
}
|
||||
|
||||
fn encode_mesh(mesh: &MeshData) -> Result<Vec<u8>> {
|
||||
@@ -410,9 +434,7 @@ struct PackageReader<R: Read + Seek> {
|
||||
impl<R: Read + Seek> PackageReader<R> {
|
||||
fn new(mut source: R) -> Result<Self> {
|
||||
let length = source.seek(SeekFrom::End(0)).map_err(invalid)?;
|
||||
if length > MAX_DESIGN_BYTES as u64 {
|
||||
return Err(invalid("compressed file too large"));
|
||||
}
|
||||
crate::limits::check(crate::limits::Kind::Design, length).map_err(invalid)?;
|
||||
let tail_length = length.min(65_557) as usize;
|
||||
source.seek(SeekFrom::Start(length - tail_length as u64)).map_err(invalid)?;
|
||||
let mut tail = vec![0; tail_length];
|
||||
@@ -457,7 +479,7 @@ impl<R: Read + Seek> PackageReader<R> {
|
||||
}
|
||||
total = total.checked_add(part.size()).ok_or_else(|| invalid("expanded size overflow"))?;
|
||||
let limit = part_limit(&name);
|
||||
if part.size() > limit as u64 || total > MAX_EXPANDED as u64 {
|
||||
if part.size() > limit as u64 || total > max_expanded() as u64 {
|
||||
return Err(invalid("expanded package too large"));
|
||||
}
|
||||
}
|
||||
@@ -514,7 +536,7 @@ impl<R: Read + Seek> PackageReader<R> {
|
||||
// Count repeated references too: a tiny archive must not expand into unbounded
|
||||
// owned document strings/arrays when the same blob is referenced repeatedly.
|
||||
self.hydrated =
|
||||
self.hydrated.checked_add(bytes.len()).filter(|&n| n <= MAX_EXPANDED).ok_or_else(|| invalid("resolved payloads too large"))?;
|
||||
self.hydrated.checked_add(bytes.len()).filter(|&n| n <= max_expanded()).ok_or_else(|| invalid("resolved payloads too large"))?;
|
||||
Ok(bytes)
|
||||
}
|
||||
}
|
||||
@@ -550,7 +572,7 @@ fn encode_preview(preview: &DesignPreview, document: &[u8]) -> Result<(Vec<u8>,
|
||||
/// Read only an optional provisional display cache; any corruption/incompatibility is a miss.
|
||||
/// The normal design reader must still validate and rebuild before enabling the design.
|
||||
pub fn read_design_preview(bytes: &[u8]) -> Option<DesignPreview> {
|
||||
if bytes.len() > MAX_DESIGN_BYTES || !is_design_container(bytes) {
|
||||
if bytes.len() > max_design() || !is_design_container(bytes) {
|
||||
return None;
|
||||
}
|
||||
DesignContainerReader::new(Cursor::new(bytes)).ok()?.preview()
|
||||
@@ -676,7 +698,7 @@ pub fn read_design_file(path: &str, notify: Option<impl FnOnce(DesignPreview)>)
|
||||
Ok((reader.read_document()?, model))
|
||||
} else {
|
||||
let mut bytes = Vec::new();
|
||||
source.take(MAX_DESIGN_BYTES as u64 + 1).read_to_end(&mut bytes).map_err(invalid)?;
|
||||
source.take((max_design() as u64).saturating_add(1)).read_to_end(&mut bytes).map_err(invalid)?;
|
||||
Ok((crate::read_design(&bytes)?, None))
|
||||
}
|
||||
}
|
||||
@@ -687,7 +709,7 @@ type FileSource = std::fs::File;
|
||||
type FileSource = Cursor<Vec<u8>>;
|
||||
|
||||
/// A file to read: inside the folders this process may use, a regular file, and at most
|
||||
/// [`MAX_DESIGN_BYTES`], read from its start.
|
||||
/// the largest design file allowed (`limits`), read from its start.
|
||||
fn open_regular_file(path: &str) -> Result<FileSource> {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let mut source = {
|
||||
@@ -696,9 +718,7 @@ fn open_regular_file(path: &str) -> Result<FileSource> {
|
||||
if !metadata.is_file() {
|
||||
return Err(invalid("not a regular file"));
|
||||
}
|
||||
if metadata.len() > MAX_DESIGN_BYTES as u64 {
|
||||
return Err(invalid("file too large"));
|
||||
}
|
||||
crate::limits::check(crate::limits::Kind::Design, metadata.len()).map_err(invalid)?;
|
||||
let file = std::fs::File::open(path).map_err(invalid)?;
|
||||
if !file.metadata().map_err(invalid)?.is_file() {
|
||||
return Err(invalid("not a regular file"));
|
||||
@@ -706,11 +726,9 @@ fn open_regular_file(path: &str) -> Result<FileSource> {
|
||||
file
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let mut source = Cursor::new(crate::vfs::read(path, MAX_DESIGN_BYTES).map_err(invalid)?);
|
||||
let mut source = Cursor::new(crate::vfs::read(path, max_design()).map_err(invalid)?);
|
||||
let size = source.seek(SeekFrom::End(0)).map_err(invalid)?;
|
||||
if size > MAX_DESIGN_BYTES as u64 {
|
||||
return Err(invalid("file too large"));
|
||||
}
|
||||
crate::limits::check(crate::limits::Kind::Design, size).map_err(invalid)?;
|
||||
source.seek(SeekFrom::Start(0)).map_err(invalid)?;
|
||||
Ok(source)
|
||||
}
|
||||
@@ -731,7 +749,7 @@ fn read_document<R: Read + Seek>(reader: &mut PackageReader<R>) -> Result<Docume
|
||||
if drawing::container_kind(reader)? == FileKind::Drawing {
|
||||
return Err(IoError::Invalid("this file is a SolidCraft drawing, not a design: open it as a drawing".into()));
|
||||
}
|
||||
let bytes = reader.document(MAX_DESIGN_BYTES)?;
|
||||
let bytes = reader.document(max_design())?;
|
||||
check_hdr_manifest(&bytes)?;
|
||||
let mut metadata: Value = serde_json::from_slice(&bytes).map_err(invalid)?;
|
||||
// HDR's typed JSON representation is deliberately strict: no empty placeholders or
|
||||
@@ -931,7 +949,7 @@ mod tests {
|
||||
}
|
||||
impl Seek for Oversized {
|
||||
fn seek(&mut self, _: SeekFrom) -> std::io::Result<u64> {
|
||||
Ok(MAX_DESIGN_BYTES as u64 + 1)
|
||||
Ok(crate::MAX_DESIGN_BYTES as u64 + 1)
|
||||
}
|
||||
}
|
||||
assert!(DesignContainerReader::new(Oversized).is_err());
|
||||
@@ -1081,7 +1099,7 @@ mod tests {
|
||||
assert!(read_design_geometry(&bytes).is_none());
|
||||
assert_eq!(crate::read_design(&bytes).unwrap().to_json(), doc.to_json());
|
||||
// With room for it, the same model is kept.
|
||||
let bytes = write_container(&doc, DesignCompression::Fast, None, Some(&native_geometry()), None, MAX_DESIGN_BYTES).unwrap();
|
||||
let bytes = write_container(&doc, DesignCompression::Fast, None, Some(&native_geometry()), None, crate::MAX_DESIGN_BYTES).unwrap();
|
||||
assert!(read_design_geometry(&bytes).is_some());
|
||||
}
|
||||
|
||||
@@ -1570,7 +1588,7 @@ mod tests {
|
||||
assert!(crate::read_design(&duplicate).is_err());
|
||||
let mut bomb = bytes.clone();
|
||||
let central = bomb.windows(4).position(|v| v == b"PK\x01\x02").unwrap();
|
||||
bomb[central + 24..central + 28].copy_from_slice(&((MAX_STEP_PART + 1) as u32).to_le_bytes());
|
||||
bomb[central + 24..central + 28].copy_from_slice(&((max_step_part() + 1) as u32).to_le_bytes());
|
||||
assert!(crate::read_design(&bomb).unwrap_err().to_string().contains("expanded package too large"));
|
||||
let mut excessive = bytes;
|
||||
let end = excessive.windows(4).rposition(|v| v == b"PK\x05\x06").unwrap();
|
||||
@@ -1623,20 +1641,20 @@ mod tests {
|
||||
/// #3221: a STEP file larger than a design part used to import, then fail to save.
|
||||
#[test]
|
||||
fn step_over_the_part_limit_imports_saves_compressed_and_reopens() {
|
||||
let step = padded_step(MAX_DESIGN_BYTES + (1 << 20), false);
|
||||
let step = padded_step(crate::MAX_DESIGN_BYTES + (1 << 20), false);
|
||||
let imported = crate::step_import_feature(step.as_bytes(), "large.step").unwrap();
|
||||
drop(step);
|
||||
let mut doc = Document::new("Large import");
|
||||
doc.add_feature(imported.kind, None).unwrap();
|
||||
let bytes = write_design_container(&doc).unwrap();
|
||||
assert!(bytes.len() < MAX_DESIGN_BYTES / 2, "saved {} MB", bytes.len() >> 20);
|
||||
assert!(bytes.len() < crate::MAX_DESIGN_BYTES / 2, "saved {} MB", bytes.len() >> 20);
|
||||
let restored = crate::read_design(&bytes).unwrap();
|
||||
let (Some(FeatureKind::Import { step: before, .. }), Some(FeatureKind::Import { step: after, .. })) =
|
||||
(doc.features.first().map(|f| &f.kind), restored.features.first().map(|f| &f.kind))
|
||||
else {
|
||||
panic!("the reopened design lost its import");
|
||||
};
|
||||
assert!(before.len() > MAX_DESIGN_BYTES && before == after, "the reopened STEP text differs");
|
||||
assert!(before.len() > crate::MAX_DESIGN_BYTES && before == after, "the reopened STEP text differs");
|
||||
let reopened = crate::step_import_feature(after.as_bytes(), "large.step").unwrap();
|
||||
assert_eq!(reopened.body_names, imported.body_names);
|
||||
assert_eq!(reopened.import.bodies.len(), 1);
|
||||
@@ -1648,10 +1666,10 @@ mod tests {
|
||||
fn mesh_larger_than_the_file_saves_compressed_and_reopens() {
|
||||
let positions: Arc<[f64]> = Arc::from([0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0]);
|
||||
let overhead = 24 + positions.len() * 8;
|
||||
let min_indices = (MAX_DESIGN_BYTES - overhead) / 4 + 1;
|
||||
let min_indices = (crate::MAX_DESIGN_BYTES - overhead) / 4 + 1;
|
||||
let indices = min_indices.div_ceil(3) * 3;
|
||||
let encoded = overhead + indices * 4;
|
||||
assert!(encoded > MAX_DESIGN_BYTES && encoded <= MAX_MESH_PART, "encoded {encoded}");
|
||||
assert!(encoded > crate::MAX_DESIGN_BYTES && encoded <= max_mesh_part(), "encoded {encoded}");
|
||||
let mesh = MeshData {
|
||||
name: "Large".into(),
|
||||
positions: Arc::clone(&positions),
|
||||
@@ -1662,7 +1680,7 @@ mod tests {
|
||||
doc.add_feature(FeatureKind::MeshImport { file: "large.stl".into(), meshes: vec![mesh] }, None).unwrap();
|
||||
for compression in [DesignCompression::Fast, DesignCompression::Compact] {
|
||||
let bytes = write_design_container_with_compression(&doc, compression).unwrap();
|
||||
assert!(bytes.len() < MAX_DESIGN_BYTES / 2, "saved {} MB", bytes.len() >> 20);
|
||||
assert!(bytes.len() < crate::MAX_DESIGN_BYTES / 2, "saved {} MB", bytes.len() >> 20);
|
||||
{
|
||||
let mut archive = zip::ZipArchive::new(Cursor::new(bytes.as_slice())).unwrap();
|
||||
let index = (0..archive.len())
|
||||
@@ -1680,10 +1698,10 @@ mod tests {
|
||||
#[test]
|
||||
fn mesh_over_the_expanded_cap_is_too_large_before_it_is_encoded() {
|
||||
assert_eq!(mesh_encoded_len(0, 0), Some(24));
|
||||
let at_cap = (MAX_MESH_PART - 24) / 4;
|
||||
assert_eq!(mesh_encoded_len(0, at_cap), Some(MAX_MESH_PART));
|
||||
let at_cap = (max_mesh_part() - 24) / 4;
|
||||
assert_eq!(mesh_encoded_len(0, at_cap), Some(max_mesh_part()));
|
||||
assert!(mesh_encoded_len(0, at_cap + 1).is_none());
|
||||
let indices = (MAX_MESH_PART / 4 + 3).div_ceil(3) * 3;
|
||||
let indices = (max_mesh_part() / 4 + 3).div_ceil(3) * 3;
|
||||
assert!(mesh_encoded_len(0, indices).is_none());
|
||||
assert!(mesh_encoded_len(usize::MAX, 0).is_none());
|
||||
assert!(mesh_encoded_len(0, usize::MAX).is_none());
|
||||
@@ -1698,7 +1716,7 @@ mod tests {
|
||||
let original = package(&entries);
|
||||
let headers: Vec<_> = original.windows(4).enumerate().filter_map(|(i, v)| (v == b"PK\x01\x02").then_some(i)).collect();
|
||||
assert_eq!(headers.len(), 2);
|
||||
for sizes in [[MAX_MESH_PART + 1, 1], [MAX_MESH_PART, MAX_MESH_PART]] {
|
||||
for sizes in [[max_mesh_part() + 1, 1], [max_mesh_part(), max_mesh_part()]] {
|
||||
let mut bytes = original.clone();
|
||||
for (header, size) in headers.iter().zip(sizes) {
|
||||
bytes[header + 24..header + 28].copy_from_slice(&(size as u32).to_le_bytes());
|
||||
@@ -1714,7 +1732,7 @@ mod tests {
|
||||
let reference = &metadata["features"][0]["meshes"][0];
|
||||
let mut reader = PackageReader::new(Cursor::new(&bytes)).unwrap();
|
||||
let length = reader.blob(reference, "mesh_blob", "mesh").unwrap().len();
|
||||
reader.hydrated = MAX_EXPANDED - length;
|
||||
reader.hydrated = max_expanded() - length;
|
||||
assert!(reader.blob(reference, "mesh_blob", "mesh").is_ok());
|
||||
assert!(reader.blob(reference, "mesh_blob", "mesh").unwrap_err().to_string().contains("resolved payloads too large"));
|
||||
}
|
||||
@@ -1749,7 +1767,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn step_that_cannot_be_saved_even_compressed_is_refused_at_import() {
|
||||
let step = padded_step(MAX_DESIGN_BYTES + (80 << 20), true);
|
||||
let step = padded_step(crate::MAX_DESIGN_BYTES + (80 << 20), true);
|
||||
let message = crate::step_import_feature(step.as_bytes(), "noisy.step").err().unwrap().to_string();
|
||||
assert!(message.contains("too large to save in a design"), "{message}");
|
||||
}
|
||||
@@ -1787,7 +1805,7 @@ mod tests {
|
||||
assert!(message.contains("declared uncompressed size") || message.contains("length mismatch"), "{message}");
|
||||
// An honest declaration over the limit is refused before the part is read at all.
|
||||
let mut over = honest;
|
||||
over[central + 24..central + 28].copy_from_slice(&((MAX_STEP_PART + 1) as u32).to_le_bytes());
|
||||
over[central + 24..central + 28].copy_from_slice(&((max_step_part() + 1) as u32).to_le_bytes());
|
||||
assert!(crate::read_design(&over).unwrap_err().to_string().contains("expanded package too large"));
|
||||
}
|
||||
|
||||
@@ -1798,7 +1816,7 @@ mod tests {
|
||||
let mut metadata: Value = serde_json::from_slice(&entries["document.json"]).unwrap();
|
||||
let reference = metadata["features"][0].clone();
|
||||
let mut reader = PackageReader::new(Cursor::new(&bytes)).unwrap();
|
||||
reader.hydrated = MAX_EXPANDED;
|
||||
reader.hydrated = max_expanded();
|
||||
assert!(reader.blob(&reference, "step_blob", "step").unwrap_err().to_string().contains("resolved payloads too large"));
|
||||
for name in ["../escape.step", "blobs/not-a-hash.step", "blobs/00.png"] {
|
||||
metadata["features"][0]["step_blob"] = json!(name);
|
||||
|
||||
@@ -50,7 +50,7 @@ pub(super) fn encode_model(model: &SavedModel, document: &[u8], space: usize) ->
|
||||
.iter()
|
||||
.map(|(s, placed)| std::iter::once(s).chain(placed.as_ref().and_then(|(part, _)| encoded.parts.get(*part))).map(|s| (*s, size(s))).collect())
|
||||
.collect();
|
||||
let mut budget = space.min(MAX_DESIGN_BYTES);
|
||||
let mut budget = space.min(max_design());
|
||||
for _ in 0..16 {
|
||||
let Some((thin, kept, counted)) = model.thinned(&pieces, budget) else { break };
|
||||
// Only the final state, which is kept whatever it costs: nothing smaller is left to try. What
|
||||
@@ -184,7 +184,7 @@ impl Encoded {
|
||||
let shares = parts.iter().map(|p| slice(*self.parts.get(*p).ok_or_else(|| invalid("display share"))?)).collect::<Result<Vec<_>>>()?;
|
||||
let stored = order.iter().map(|s| self.slices.get(*s).ok_or_else(|| invalid("cached body"))).collect::<Result<Vec<_>>>()?;
|
||||
let length = stored.iter().fold(0usize, |n, bytes| n.saturating_add(bytes.len()));
|
||||
if length > MAX_DESIGN_BYTES || stored.len() > MAX_UNIQUE {
|
||||
if length > max_design() || stored.len() > MAX_UNIQUE {
|
||||
return Err(invalid("model cache size"));
|
||||
}
|
||||
let mut data = Vec::with_capacity(length);
|
||||
@@ -206,7 +206,7 @@ impl Encoded {
|
||||
/// The final state of the model a design keeps, when this build computed it for exactly this
|
||||
/// document. Any failure is a miss, never a document error.
|
||||
pub fn read_design_geometry(bytes: &[u8]) -> Option<std::sync::Arc<ModelState>> {
|
||||
if bytes.len() > MAX_DESIGN_BYTES || !is_design_container(bytes) {
|
||||
if bytes.len() > max_design() || !is_design_container(bytes) {
|
||||
return None;
|
||||
}
|
||||
DesignContainerReader::new(Cursor::new(bytes)).ok()?.geometry()?.final_state().ok()
|
||||
@@ -241,7 +241,7 @@ pub(super) fn read_geometry_with<R: Read + Seek>(reader: &mut PackageReader<R>,
|
||||
}
|
||||
// Validate the small parametric metadata before decoding any geometry.
|
||||
Document::from_json(std::str::from_utf8(document).map_err(invalid)?)?;
|
||||
let data = reader.limited_part(PAYLOAD, MAX_DESIGN_BYTES)?;
|
||||
let data = reader.limited_part(PAYLOAD, max_design())?;
|
||||
if manifest.get("payload").and_then(Value::as_str) != Some(digest(&data).as_str()) {
|
||||
return Err(invalid("model cache payload key"));
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ pub(super) fn write(writer: &mut PackageWriter, png: &[u8], document: &[u8]) ->
|
||||
}
|
||||
let key = serde_json::to_vec(&json!({"format": FORMAT, "app": env!("CARGO_PKG_VERSION"), "document": digest(document), "payload": digest(png)}))
|
||||
.map_err(invalid)?;
|
||||
if !writer.room(2, key.len().saturating_add(png.len()), MAX_DESIGN_BYTES) {
|
||||
if !writer.room(2, key.len().saturating_add(png.len()), max_design()) {
|
||||
return Ok(());
|
||||
}
|
||||
writer.part("cache/thumbnail.json", &key, false)?;
|
||||
@@ -54,17 +54,17 @@ pub fn read_design_thumbnail_file(path: &str) -> Option<Vec<u8>> {
|
||||
let source = {
|
||||
crate::vfs::check(path).ok()?;
|
||||
let metadata = std::fs::metadata(path).ok()?;
|
||||
if !metadata.is_file() || metadata.len() > MAX_DESIGN_BYTES as u64 {
|
||||
if !metadata.is_file() || metadata.len() > max_design() as u64 {
|
||||
return None;
|
||||
}
|
||||
let source = std::fs::File::open(path).ok()?;
|
||||
let metadata = source.metadata().ok()?;
|
||||
if !metadata.is_file() || metadata.len() > MAX_DESIGN_BYTES as u64 {
|
||||
if !metadata.is_file() || metadata.len() > max_design() as u64 {
|
||||
return None;
|
||||
}
|
||||
source
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let source = Cursor::new(crate::vfs::read(path, MAX_DESIGN_BYTES).ok()?);
|
||||
let source = Cursor::new(crate::vfs::read(path, max_design()).ok()?);
|
||||
DesignContainerReader::new(source).ok()?.thumbnail()
|
||||
}
|
||||
@@ -20,6 +20,7 @@ pub use design::{
|
||||
write_design_container_with_thumbnail, write_drawing_container,
|
||||
};
|
||||
mod legacy_dir;
|
||||
pub mod limits;
|
||||
#[cfg(test)]
|
||||
mod mutate;
|
||||
mod native_cad;
|
||||
@@ -79,7 +80,7 @@ pub const DRAWING_EXT: &str = "scdwg";
|
||||
pub fn is_drawing_path(path: &str) -> bool {
|
||||
std::path::Path::new(path).extension().and_then(|e| e.to_str()).is_some_and(|e| e.eq_ignore_ascii_case(DRAWING_EXT))
|
||||
}
|
||||
/// Largest design file we read.
|
||||
/// Largest design file read by default; the desktop app may raise it ([`limits`], #4086).
|
||||
pub const MAX_DESIGN_BYTES: usize = 256 << 20;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
@@ -98,7 +99,7 @@ pub enum IoError {
|
||||
|
||||
pub type Result<T> = std::result::Result<T, IoError>;
|
||||
|
||||
/// Largest STEP file we read.
|
||||
/// Largest STEP (or import) file read by default; the desktop app may raise it ([`limits`], #4086).
|
||||
pub const MAX_STEP_BYTES: usize = 512 << 20;
|
||||
|
||||
/// Is this a CAD file read as an Import base feature: STEP (`.step` / `.stp`), IGES
|
||||
@@ -225,9 +226,7 @@ pub fn step_import_feature(bytes: &[u8], file: &str) -> Result<StepFeature> {
|
||||
|
||||
/// [`step_import_feature`], with the bodies named after `names`.
|
||||
pub fn step_import_feature_named(bytes: &[u8], file: &str, names: StepNames) -> Result<StepFeature> {
|
||||
if bytes.len() > MAX_STEP_BYTES {
|
||||
return Err(IoError::Invalid(format!("STEP file too large ({} MB, limit {} MB)", bytes.len() >> 20, MAX_STEP_BYTES >> 20)));
|
||||
}
|
||||
limits::check(limits::Kind::Step, bytes.len() as u64).map_err(IoError::Invalid)?;
|
||||
// STEP is 7-bit text with escapes; tolerate stray 8-bit bytes. IGES and the cadmpeg formats
|
||||
// are restated as STEP (the feature keeps that STEP text).
|
||||
let (text, iges_warnings) = if is_native_cad_path(file) {
|
||||
@@ -787,9 +786,7 @@ pub fn step_assembly(doc: &Document, local: &ModelState, name: &str) -> Result<V
|
||||
|
||||
/// Read a design file's bytes.
|
||||
pub fn read_design(bytes: &[u8]) -> Result<Document> {
|
||||
if bytes.len() > MAX_DESIGN_BYTES {
|
||||
return Err(IoError::Invalid("design file too large".into()));
|
||||
}
|
||||
limits::check(limits::Kind::Design, bytes.len() as u64).map_err(|e| IoError::Invalid(format!("design {e}")))?;
|
||||
if is_design_container(bytes) {
|
||||
return design::read(bytes);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
//! The largest files SolidCraft reads (#4086). [`crate::MAX_STEP_BYTES`] and
|
||||
//! [`crate::MAX_DESIGN_BYTES`] are the defaults; the desktop app may raise them (Preferences ›
|
||||
//! General › Largest file to open, saved by the app) or for one run (`--max-file-size`), never
|
||||
//! past [`CEILING`]. Every read site asks [`max_step_bytes`] / [`max_design_bytes`] for the limit
|
||||
//! in force, so the size check still happens before a file is read. In the browser (wasm32) the
|
||||
//! defaults always apply: the web app's address space can't hold more.
|
||||
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
/// One megabyte as the limits count it (2^20 bytes, like the defaults).
|
||||
pub const MB: u64 = 1 << 20;
|
||||
/// One gigabyte (2^30 bytes).
|
||||
pub const GB: u64 = 1 << 30;
|
||||
/// The highest limit either kind may be raised to.
|
||||
pub const CEILING: u64 = 16 * GB;
|
||||
/// Whether this build lets the limits rise: not in the browser.
|
||||
pub const ADJUSTABLE: bool = cfg!(not(target_arch = "wasm32"));
|
||||
|
||||
/// The two kinds of file with a size limit.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Kind {
|
||||
/// STEP, IGES and the other CAD files read as an Import feature.
|
||||
Step,
|
||||
/// Design files (`.sc`, older `.solidcraft`, JSON).
|
||||
Design,
|
||||
}
|
||||
|
||||
impl Kind {
|
||||
/// The limit in force for this kind, in bytes.
|
||||
pub fn limit(self) -> u64 {
|
||||
let l = effective();
|
||||
match self {
|
||||
Kind::Step => l.step,
|
||||
Kind::Design => l.design,
|
||||
}
|
||||
}
|
||||
|
||||
fn what(self) -> &'static str {
|
||||
match self {
|
||||
Kind::Step => "STEP and import files",
|
||||
Kind::Design => "design files",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The largest STEP/import file and the largest design file, in bytes.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct FileLimits {
|
||||
pub step: u64,
|
||||
pub design: u64,
|
||||
}
|
||||
|
||||
impl Default for FileLimits {
|
||||
fn default() -> Self {
|
||||
Self::DEFAULT
|
||||
}
|
||||
}
|
||||
|
||||
impl FileLimits {
|
||||
/// The limits SolidCraft has always had.
|
||||
pub const DEFAULT: Self = Self { step: crate::MAX_STEP_BYTES as u64, design: crate::MAX_DESIGN_BYTES as u64 };
|
||||
|
||||
/// Limits from whole megabytes, as the preference keeps them.
|
||||
pub fn from_mb(step_mb: u64, design_mb: u64) -> Self {
|
||||
Self { step: step_mb.saturating_mul(MB), design: design_mb.saturating_mul(MB) }
|
||||
}
|
||||
|
||||
/// One size for both kinds (`--max-file-size`). A kind whose default is larger keeps its
|
||||
/// default: the flag only ever raises a limit.
|
||||
pub fn both(bytes: u64) -> Self {
|
||||
Self { step: bytes.max(Self::DEFAULT.step), design: bytes.max(Self::DEFAULT.design) }
|
||||
}
|
||||
|
||||
/// These limits, if each is between its default and [`ceiling`].
|
||||
pub fn validate(self) -> Result<Self, String> {
|
||||
for (kind, value, default) in [(Kind::Step, self.step, Self::DEFAULT.step), (Kind::Design, self.design, Self::DEFAULT.design)] {
|
||||
if value < default || value > ceiling() {
|
||||
return Err(format!(
|
||||
"the limit for {} must be between {} and {}, not {}",
|
||||
kind.what(),
|
||||
describe(default),
|
||||
describe(ceiling()),
|
||||
describe(value)
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
/// These limits brought into range (a hand-edited settings file).
|
||||
pub fn clamped(self) -> Self {
|
||||
Self {
|
||||
step: self.step.clamp(Self::DEFAULT.step, ceiling().max(Self::DEFAULT.step)),
|
||||
design: self.design.clamp(Self::DEFAULT.design, ceiling().max(Self::DEFAULT.design)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// [`CEILING`], or less where the platform can't address that much.
|
||||
pub fn ceiling() -> u64 {
|
||||
if !ADJUSTABLE {
|
||||
return FileLimits::DEFAULT.step.max(FileLimits::DEFAULT.design);
|
||||
}
|
||||
CEILING.min(u64::try_from(usize::MAX).unwrap_or(u64::MAX))
|
||||
}
|
||||
|
||||
static PREFERRED_STEP: AtomicU64 = AtomicU64::new(FileLimits::DEFAULT.step);
|
||||
static PREFERRED_DESIGN: AtomicU64 = AtomicU64::new(FileLimits::DEFAULT.design);
|
||||
/// `--max-file-size` for this run, in bytes; 0 when not given.
|
||||
static OVERRIDE: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
/// Use these limits from now on (the saved preference). Refused, changing nothing, when out of
|
||||
/// range, and in the browser for anything but the defaults.
|
||||
pub fn set_preferred(limits: FileLimits) -> Result<(), String> {
|
||||
if !ADJUSTABLE && limits != FileLimits::DEFAULT {
|
||||
return Err(BROWSER_NOTE.into());
|
||||
}
|
||||
let limits = limits.validate()?;
|
||||
PREFERRED_STEP.store(limits.step, Ordering::Relaxed);
|
||||
PREFERRED_DESIGN.store(limits.design, Ordering::Relaxed);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The saved preference's limits, whether or not `--max-file-size` overrides them.
|
||||
pub fn preferred() -> FileLimits {
|
||||
FileLimits { step: PREFERRED_STEP.load(Ordering::Relaxed), design: PREFERRED_DESIGN.load(Ordering::Relaxed) }
|
||||
}
|
||||
|
||||
/// `--max-file-size` for this run (`None` clears it). Refused above [`ceiling`], and in the browser.
|
||||
pub fn set_override(bytes: Option<u64>) -> Result<(), String> {
|
||||
match bytes {
|
||||
None => OVERRIDE.store(0, Ordering::Relaxed),
|
||||
Some(_) if !ADJUSTABLE => return Err(BROWSER_NOTE.into()),
|
||||
Some(b) => {
|
||||
check_flag(b)?;
|
||||
OVERRIDE.store(b, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The `--max-file-size` this run started with, in bytes.
|
||||
pub fn override_bytes() -> Option<u64> {
|
||||
Some(OVERRIDE.load(Ordering::Relaxed)).filter(|&b| b > 0 && ADJUSTABLE)
|
||||
}
|
||||
|
||||
/// The limits in force: `--max-file-size` if given, else the preference; the defaults in the browser.
|
||||
pub fn effective() -> FileLimits {
|
||||
resolve(ADJUSTABLE, preferred(), OVERRIDE.load(Ordering::Relaxed))
|
||||
}
|
||||
|
||||
/// The limits in force from the preference and the flag (0: none); always the defaults where the
|
||||
/// build can't raise them (`adjustable` false: the browser).
|
||||
fn resolve(adjustable: bool, preferred: FileLimits, flag: u64) -> FileLimits {
|
||||
if !adjustable {
|
||||
FileLimits::DEFAULT
|
||||
} else if flag > 0 {
|
||||
FileLimits::both(flag)
|
||||
} else {
|
||||
preferred
|
||||
}
|
||||
}
|
||||
|
||||
/// The largest STEP or import file read now.
|
||||
pub fn max_step_bytes() -> usize {
|
||||
usize::try_from(effective().step).unwrap_or(usize::MAX)
|
||||
}
|
||||
|
||||
/// The largest design file read (and written) now.
|
||||
pub fn max_design_bytes() -> usize {
|
||||
usize::try_from(effective().design).unwrap_or(usize::MAX)
|
||||
}
|
||||
|
||||
const BROWSER_NOTE: &str = "the web app can't open larger files: a browser tab can't hold them";
|
||||
|
||||
/// How to raise a limit, for the messages that refuse a file.
|
||||
pub fn how_to_raise() -> &'static str {
|
||||
if ADJUSTABLE {
|
||||
"Raise the limit in Preferences > General > Largest file to open, or start SolidCraft with --max-file-size (for example --max-file-size 2GB)."
|
||||
} else {
|
||||
"The web app can't open larger files; the desktop app can raise the limit."
|
||||
}
|
||||
}
|
||||
|
||||
/// The message refusing a `size`-byte file of this kind.
|
||||
pub fn too_large(kind: Kind, size: u64) -> String {
|
||||
format!("file too large ({}; the limit for {} is {}). {}", describe(size), kind.what(), describe(kind.limit()), how_to_raise())
|
||||
}
|
||||
|
||||
/// Refuse a `size`-byte file of this kind before it is read.
|
||||
pub fn check(kind: Kind, size: u64) -> Result<(), String> {
|
||||
if size > kind.limit() { Err(too_large(kind, size)) } else { Ok(()) }
|
||||
}
|
||||
|
||||
/// [`crate::vfs::read`] with this kind's limit; a file over it is refused, before reading, with
|
||||
/// [`too_large`]'s message.
|
||||
pub fn read(path: &str, kind: Kind) -> std::io::Result<Vec<u8>> {
|
||||
if let Ok(size) = crate::vfs::len(path) {
|
||||
check(kind, size).map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidData, e))?;
|
||||
}
|
||||
crate::vfs::read(path, usize::try_from(kind.limit()).unwrap_or(usize::MAX)).map_err(|e| explain(kind, e))
|
||||
}
|
||||
|
||||
/// A read error from [`crate::vfs`] at this kind's limit, with the refusal of a file over it
|
||||
/// saying how to raise the limit.
|
||||
pub fn explain(kind: Kind, error: std::io::Error) -> std::io::Error {
|
||||
if error.kind() == std::io::ErrorKind::InvalidData && error.to_string() == "file too large" {
|
||||
let message = format!("file too large (over the {} limit for {}). {}", describe(kind.limit()), kind.what(), how_to_raise());
|
||||
std::io::Error::new(std::io::ErrorKind::InvalidData, message)
|
||||
} else {
|
||||
error
|
||||
}
|
||||
}
|
||||
|
||||
/// A size as people write it: whole gigabytes as `2 GB`, anything else in megabytes.
|
||||
pub fn describe(bytes: u64) -> String {
|
||||
if bytes >= GB && bytes.is_multiple_of(GB) {
|
||||
format!("{} GB", bytes / GB)
|
||||
} else if bytes >= GB {
|
||||
format!("{:.1} GB", bytes as f64 / GB as f64)
|
||||
} else {
|
||||
format!("{} MB", bytes.div_ceil(MB))
|
||||
}
|
||||
}
|
||||
|
||||
/// A size such as `2GB`, `1.5 GB`, `1500MB` or `1500M` (megabytes and gigabytes of 2^20 and 2^30
|
||||
/// bytes, any case), in bytes. A number needs its unit.
|
||||
pub fn parse_size(text: &str) -> Result<u64, String> {
|
||||
let t = text.trim();
|
||||
let split = t.find(|c: char| !(c.is_ascii_digit() || c == '.')).unwrap_or(t.len());
|
||||
let (number, unit) = (t.get(..split).unwrap_or(""), t.get(split..).unwrap_or("").trim());
|
||||
let unit_bytes = match unit.to_ascii_uppercase().as_str() {
|
||||
"MB" | "M" | "MIB" => MB,
|
||||
"GB" | "G" | "GIB" => GB,
|
||||
"" => return Err(format!("`{t}` needs a unit: write it as, for example, 2GB or 1500MB")),
|
||||
_ => return Err(format!("`{t}`: the unit must be MB or GB")),
|
||||
};
|
||||
let value: f64 = number.parse().map_err(|_| format!("`{t}` is not a size such as 2GB or 1500MB"))?;
|
||||
if !value.is_finite() || value <= 0.0 || value > 1e9 {
|
||||
return Err(format!("`{t}` is not a size such as 2GB or 1500MB"));
|
||||
}
|
||||
let bytes = (value * unit_bytes as f64).round();
|
||||
// Below 2^63, so the conversion is exact enough and never saturates.
|
||||
if bytes >= 9.0e18 {
|
||||
return Err(format!("`{t}` is over the {} limit", describe(ceiling())));
|
||||
}
|
||||
Ok(bytes as u64)
|
||||
}
|
||||
|
||||
/// A `--max-file-size` value must be at least 1 MB and at most [`ceiling`].
|
||||
fn check_flag(bytes: u64) -> Result<u64, String> {
|
||||
if bytes < MB {
|
||||
return Err("--max-file-size must be at least 1MB".into());
|
||||
}
|
||||
if bytes > ceiling() {
|
||||
return Err(format!("--max-file-size can be at most {}, not {}", describe(ceiling()), describe(bytes)));
|
||||
}
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
/// Parse a `--max-file-size` value ([`parse_size`], then the range check).
|
||||
pub fn parse_flag(text: &str) -> Result<u64, String> {
|
||||
if !ADJUSTABLE {
|
||||
return Err(BROWSER_NOTE.into());
|
||||
}
|
||||
check_flag(parse_size(text)?)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_defaults_are_the_limits_there_always_were() {
|
||||
assert_eq!(FileLimits::default(), FileLimits { step: 512 * MB, design: 256 * MB });
|
||||
// Nothing in this test binary raises the limits: the read sites see the defaults.
|
||||
assert_eq!((max_step_bytes(), max_design_bytes()), (crate::MAX_STEP_BYTES, crate::MAX_DESIGN_BYTES));
|
||||
assert_eq!(FileLimits::from_mb(512, 256), FileLimits::DEFAULT);
|
||||
assert!(FileLimits::DEFAULT.validate().is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sizes_parse_with_their_units_and_bad_ones_are_refused() {
|
||||
for (text, bytes) in
|
||||
[("2GB", 2 * GB), ("2 gb", 2 * GB), ("1.5GB", 3 * GB / 2), ("1500MB", 1500 * MB), ("1500m", 1500 * MB), ("16GiB", 16 * GB)]
|
||||
{
|
||||
assert_eq!(parse_size(text), Ok(bytes), "{text}");
|
||||
}
|
||||
for text in ["", "2", "GB", "2TB", "-1GB", "1e3MB", "0GB", "NaNGB", "1.2.3GB", "99999999999GB"] {
|
||||
assert!(parse_size(text).is_err(), "{text}");
|
||||
}
|
||||
if ADJUSTABLE {
|
||||
assert_eq!(parse_flag("16GB"), Ok(CEILING));
|
||||
let over = parse_flag("17GB").unwrap_err();
|
||||
assert!(over.contains("at most 16 GB"), "{over}");
|
||||
assert!(parse_flag("0.5MB").is_err());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn limits_are_refused_outside_the_default_to_the_ceiling() {
|
||||
assert!(FileLimits { step: 4 * GB, design: 2 * GB }.validate().is_ok() || !ADJUSTABLE);
|
||||
let over = FileLimits { step: CEILING + MB, ..FileLimits::DEFAULT }.validate().unwrap_err();
|
||||
assert!(over.contains("STEP and import files"), "{over}");
|
||||
assert!(FileLimits { design: 100 * MB, ..FileLimits::DEFAULT }.validate().is_err());
|
||||
let wild = FileLimits { step: u64::MAX, design: 0 }.clamped();
|
||||
assert_eq!(wild, FileLimits { step: ceiling().max(FileLimits::DEFAULT.step), design: FileLimits::DEFAULT.design });
|
||||
// The flag never lowers a limit below its default.
|
||||
assert_eq!(FileLimits::both(300 * MB), FileLimits { step: 512 * MB, design: 300 * MB });
|
||||
assert_eq!(FileLimits::both(2 * GB), FileLimits { step: 2 * GB, design: 2 * GB });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_refused_file_says_how_to_raise_the_limit() {
|
||||
let message = too_large(Kind::Step, 600 * MB);
|
||||
assert!(message.contains("600 MB") && message.contains("512 MB"), "{message}");
|
||||
if ADJUSTABLE {
|
||||
assert!(message.contains("Preferences > General > Largest file to open") && message.contains("--max-file-size"), "{message}");
|
||||
}
|
||||
assert!(check(Kind::Design, 256 * MB).is_ok() && check(Kind::Design, 256 * MB + 1).is_err());
|
||||
assert_eq!(describe(2 * GB), "2 GB");
|
||||
assert_eq!(describe(1536 * MB), "1.5 GB");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_flag_overrides_the_preference_and_the_browser_keeps_the_defaults() {
|
||||
let preferred = FileLimits { step: 4 * GB, design: GB };
|
||||
assert_eq!(resolve(true, preferred, 0), preferred);
|
||||
assert_eq!(resolve(true, preferred, 2 * GB), FileLimits { step: 2 * GB, design: 2 * GB });
|
||||
// The browser (wasm32) build: neither the preference nor a flag raises anything.
|
||||
assert_eq!(resolve(false, preferred, 2 * GB), FileLimits::DEFAULT);
|
||||
if !ADJUSTABLE {
|
||||
assert!(set_preferred(preferred).is_err() && set_override(Some(2 * GB)).is_err());
|
||||
assert_eq!(effective(), FileLimits::DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ mod convert {
|
||||
pub(super) fn policy() -> DecodePolicy {
|
||||
DecodePolicy {
|
||||
mode: DecodeMode::Salvage,
|
||||
limits: ResourceLimits { max_input_bytes: crate::MAX_STEP_BYTES as u64, ..ResourceLimits::service() },
|
||||
limits: ResourceLimits { max_input_bytes: crate::limits::Kind::Step.limit(), ..ResourceLimits::service() },
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -623,7 +623,7 @@ fn step_staged(running: &mut Running) {
|
||||
// Parse and walk the file. The reading keeps the watch: its steps report progress and
|
||||
// stop on Cancel.
|
||||
let read = solidcraft_engine::io::vfs::scoped(scope, || {
|
||||
let bytes = solidcraft_engine::io::vfs::read(&path, solidcraft_engine::io::MAX_STEP_BYTES).map_err(|e| format!("{path}: {e}"))?;
|
||||
let bytes = solidcraft_engine::io::limits::read(&path, solidcraft_engine::io::limits::Kind::Step).map_err(|e| format!("{path}: {e}"))?;
|
||||
// The same text the import command makes of the bytes, so it finds this reading.
|
||||
let text = String::from_utf8_lossy(&bytes).into_owned();
|
||||
solidcraft_engine::doc::progress::watch(progress.clone(), || solidcraft_engine::kernel::StepReading::new(&text))
|
||||
|
||||
@@ -978,6 +978,8 @@ impl SolveApp {
|
||||
}
|
||||
// Before a design given at start opens: its paths follow the network preferences.
|
||||
prefs::apply_network(&self.preferences);
|
||||
// Before a file given at start opens: the largest file it may be (#4086).
|
||||
prefs::apply_file_limits(&self.preferences);
|
||||
// Saved before the theme was a preference: the Dark/Light flag says which.
|
||||
if v.get("preferences").and_then(|p| p.get("theme")).is_none() {
|
||||
self.preferences.theme = if self.ui.dark { "dark" } else { "light" }.into();
|
||||
|
||||
@@ -611,6 +611,27 @@ impl SpaceMouseDriver {
|
||||
}
|
||||
}
|
||||
|
||||
/// The default largest STEP/import file, in MB (`solidcraft_io::MAX_STEP_BYTES`).
|
||||
pub const DEFAULT_STEP_MB: u64 = solidcraft_engine::io::limits::FileLimits::DEFAULT.step / solidcraft_engine::io::limits::MB;
|
||||
/// The default largest design file, in MB (`solidcraft_io::MAX_DESIGN_BYTES`).
|
||||
pub const DEFAULT_DESIGN_MB: u64 = solidcraft_engine::io::limits::FileLimits::DEFAULT.design / solidcraft_engine::io::limits::MB;
|
||||
|
||||
/// The file size limits the preferences ask for (Preferences › General › Largest file to open),
|
||||
/// brought into range.
|
||||
pub fn file_limits(p: &Prefs) -> solidcraft_engine::io::limits::FileLimits {
|
||||
solidcraft_engine::io::limits::FileLimits::from_mb(p.max_step_file_mb, p.max_design_file_mb).clamped()
|
||||
}
|
||||
|
||||
/// Every read from now on uses the preferred file size limits (unless `--max-file-size` gave
|
||||
/// this run its own). The browser keeps its defaults.
|
||||
pub fn apply_file_limits(p: &Prefs) {
|
||||
if solidcraft_engine::io::limits::ADJUSTABLE
|
||||
&& let Err(e) = solidcraft_engine::io::limits::set_preferred(file_limits(p))
|
||||
{
|
||||
log::warn!("preferences: file size limits: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The browser sidebar's first width, and the width [`Prefs::default`] restores; the panel
|
||||
/// itself clamps what the user drags to its own range.
|
||||
pub const DEFAULT_BROWSER_WIDTH: f32 = 250.0;
|
||||
@@ -835,6 +856,11 @@ preference_settings! {
|
||||
reopen_designs: bool = true, PAGE_GENERAL;
|
||||
/// Those designs' files, in tab order, as the last quit left them.
|
||||
open_designs: Vec<String> = Vec::new(), PAGE_GENERAL;
|
||||
/// The largest STEP or import file opened, in MB (#4086): from the default (512) up to 16 GB.
|
||||
/// `--max-file-size` overrides it for one run. The browser keeps the default.
|
||||
max_step_file_mb: u64 = DEFAULT_STEP_MB, PAGE_GENERAL;
|
||||
/// The largest design file opened or saved, in MB (#4086): from the default (256) up to 16 GB.
|
||||
max_design_file_mb: u64 = DEFAULT_DESIGN_MB, PAGE_GENERAL;
|
||||
/// `dark`, `light` or `system` (follow the operating system), or a theme file's id: a
|
||||
/// built-in one (`gruvbox-dark`, …) or one of `custom_themes` (#2255).
|
||||
theme: String = "dark".into(), PAGE_INTERFACE;
|
||||
@@ -1534,6 +1560,7 @@ fn defaults(app: &mut SolveApp, page: usize) {
|
||||
/// the interface scale.
|
||||
pub fn apply(app: &mut SolveApp, ctx: &egui::Context) {
|
||||
apply_network(&app.preferences);
|
||||
apply_file_limits(&app.preferences);
|
||||
// The viewport's display quality (an unknown saved value draws at Normal).
|
||||
solidcraft_engine::doc::display_quality::set_current(
|
||||
solidcraft_engine::doc::display_quality::DisplayQuality::parse(&app.preferences.display_quality).unwrap_or_default(),
|
||||
@@ -2816,6 +2843,11 @@ pub fn migrate(mut p: Prefs) -> Prefs {
|
||||
/// so a hand-edited preferences file cannot carry a huge or nonsense list. `set` still refuses
|
||||
/// those instead of dropping them.
|
||||
fn limit_disabled_plugins(mut p: Prefs) -> Prefs {
|
||||
// The file size limits, likewise, are brought into range (#4086).
|
||||
let limits = file_limits(&p);
|
||||
let mb = solidcraft_engine::io::limits::MB;
|
||||
(p.max_step_file_mb, p.max_design_file_mb) =
|
||||
if solidcraft_engine::io::limits::ADJUSTABLE { (limits.step / mb, limits.design / mb) } else { (DEFAULT_STEP_MB, DEFAULT_DESIGN_MB) };
|
||||
p.disabled_plugins.retain(|id| crate::plugins::valid_id(id));
|
||||
if p.disabled_plugins.len() > crate::plugins::MAX_DISABLED {
|
||||
p.disabled_plugins = p.disabled_plugins.into_iter().take(crate::plugins::MAX_DISABLED).collect();
|
||||
@@ -2913,6 +2945,22 @@ pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::Valu
|
||||
if new.disabled_plugins.len() > crate::plugins::MAX_DISABLED || new.disabled_plugins.iter().any(|id| !crate::plugins::valid_id(id)) {
|
||||
return Err(format!("`disabled_plugins` must be at most {} ids of lowercase letters, digits and hyphens", crate::plugins::MAX_DISABLED));
|
||||
}
|
||||
if new.max_step_file_mb != app.preferences.max_step_file_mb || new.max_design_file_mb != app.preferences.max_design_file_mb {
|
||||
let mb = solidcraft_engine::io::limits::MB;
|
||||
let wanted = solidcraft_engine::io::limits::FileLimits {
|
||||
step: new.max_step_file_mb.saturating_mul(mb),
|
||||
design: new.max_design_file_mb.saturating_mul(mb),
|
||||
};
|
||||
if !solidcraft_engine::io::limits::ADJUSTABLE && wanted != solidcraft_engine::io::limits::FileLimits::DEFAULT {
|
||||
return Err("`max_step_file_mb` and `max_design_file_mb` can't change in the web app: a browser tab can't hold larger files".into());
|
||||
}
|
||||
wanted.validate().map_err(|e| {
|
||||
format!(
|
||||
"`max_step_file_mb` must be {DEFAULT_STEP_MB}…{max} and `max_design_file_mb` {DEFAULT_DESIGN_MB}…{max}: {e}",
|
||||
max = solidcraft_engine::io::limits::ceiling() / mb
|
||||
)
|
||||
})?;
|
||||
}
|
||||
if !accepted::ui_scale(&new) || !accepted::look_at_speed(&new) {
|
||||
return Err("`ui_scale` must be 0.5…2.5 and `look_at_speed` 0.25…4".into());
|
||||
}
|
||||
@@ -2937,6 +2985,7 @@ pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::Valu
|
||||
app.ui.layout = new.layout;
|
||||
}
|
||||
app.preferences = new;
|
||||
apply_file_limits(&app.preferences);
|
||||
if units_changed {
|
||||
default_units_changed(app);
|
||||
}
|
||||
@@ -5006,6 +5055,40 @@ mod tests {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// Preferences › General › Largest file to open (#4086): the defaults are the limits there always
|
||||
/// were; `ui.prefs` raises both, up to 16 GB and never below the defaults; a saved value out of
|
||||
/// range reads back in range, and General's Restore Defaults puts them back.
|
||||
#[test]
|
||||
fn the_largest_file_to_open_defaults_raises_and_refuses_out_of_range() {
|
||||
use serde_json::json;
|
||||
use solidcraft_engine::io::limits::{FileLimits, GB};
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
assert_eq!((h.app.preferences.max_step_file_mb, h.app.preferences.max_design_file_mb), (512, 256));
|
||||
assert_eq!(super::file_limits(&h.app.preferences), FileLimits::DEFAULT);
|
||||
let out = h.call("ui.prefs", json!({"max_step_file_mb": 4096, "max_design_file_mb": 2048}));
|
||||
assert_eq!((out["result"]["max_step_file_mb"].as_u64(), out["result"]["max_design_file_mb"].as_u64()), (Some(4096), Some(2048)), "{out}");
|
||||
assert_eq!(super::file_limits(&h.app.preferences), FileLimits { step: 4 * GB, design: 2 * GB });
|
||||
for bad in [
|
||||
json!({"max_step_file_mb": 16385}),
|
||||
json!({"max_design_file_mb": 100}),
|
||||
json!({"max_step_file_mb": -1}),
|
||||
json!({"max_design_file_mb": "2GB"}),
|
||||
] {
|
||||
assert!(h.call("ui.prefs", bad.clone())["error"].is_string(), "{bad}");
|
||||
}
|
||||
assert_eq!(super::file_limits(&h.app.preferences), FileLimits { step: 4 * GB, design: 2 * GB }, "a refused value changes nothing");
|
||||
let read = super::lenient(&json!({"max_step_file_mb": 999_999, "max_design_file_mb": 3}));
|
||||
assert_eq!((read.max_step_file_mb, read.max_design_file_mb), (16384, 256));
|
||||
|
||||
h.call("ui.prefs", json!({"open": "General"}));
|
||||
h.frames(2);
|
||||
super::reveal_preference(&mut h, "prefs:max_step_file_mb");
|
||||
assert!(crate::scenario::rect_of("prefs:max_design_file_mb").is_some());
|
||||
h.call("ui.prefs", json!({"button": "defaults"}));
|
||||
assert_eq!(super::file_limits(&h.app.preferences), FileLimits::DEFAULT);
|
||||
h.call("ui.prefs", json!({"button": "cancel"}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn graphics_card_picker_selects_named_cards_and_restores_automatic() {
|
||||
let dir = std::env::temp_dir().join(format!("solidcraft-graphics-picker-{}", std::process::id()));
|
||||
|
||||
@@ -49,6 +49,7 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
ui_kit::text(ui, app.tr("prefs.crash_reports_note"), ui_kit::Text::Hint("crash_reports"));
|
||||
});
|
||||
});
|
||||
ui_kit::settings_section(ui, "file_size", app.tr("prefs.max_file_size"), |ui| file_size_rows(app, ui, labels));
|
||||
ui_kit::settings_section(ui, "slicer", app.tr("ui.slicer"), |ui| {
|
||||
ui_kit::settings_block(ui, app.tr("ui.slicer"), labels, |ui| {
|
||||
let (single, tip) = (app.tr("ui.slicer_single_instance").to_string(), app.tr("ui.slicer_single_instance_tip").to_string());
|
||||
@@ -59,3 +60,39 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
ui_kit::settings_block(ui, app.tr("update.prefs_label"), labels, |ui| crate::update::prefs_rows(app, ui));
|
||||
});
|
||||
}
|
||||
|
||||
/// Preferences › General › Largest file to open (#4086): the STEP/import and design file limits,
|
||||
/// in MB. The browser keeps its limits, so there it is a note instead.
|
||||
fn file_size_rows(app: &mut SolveApp, ui: &mut egui::Ui, labels: f32) {
|
||||
use solidcraft_engine::io::limits;
|
||||
if !limits::ADJUSTABLE {
|
||||
ui_kit::text(ui, app.tr("prefs.max_file_size_web"), ui_kit::Text::Hint("max_file_size"));
|
||||
return;
|
||||
}
|
||||
let top = limits::ceiling() / limits::MB;
|
||||
let (step, design) = (app.tr("prefs.max_file_size_step"), app.tr("prefs.max_file_size_design"));
|
||||
let rows = [
|
||||
(step, "prefs:max_step_file_mb", DEFAULT_STEP_MB, &mut app.preferences.max_step_file_mb),
|
||||
(design, "prefs:max_design_file_mb", DEFAULT_DESIGN_MB, &mut app.preferences.max_design_file_mb),
|
||||
];
|
||||
for (label, handle, default, value) in rows {
|
||||
ui_kit::settings_block(ui, label, labels, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
let field = ui_kit::settings_number(ui, value, default..=top, 1.0);
|
||||
crate::scenario::publish_rect(handle, field.rect);
|
||||
let size = limits::describe(value.saturating_mul(limits::MB));
|
||||
let note = if *value >= 1024 {
|
||||
format!("{} ({size})", crate::i18n::tr("prefs.megabytes"))
|
||||
} else {
|
||||
crate::i18n::tr("prefs.megabytes").to_string()
|
||||
};
|
||||
ui_kit::settings_inline_note(ui, ¬e);
|
||||
});
|
||||
});
|
||||
}
|
||||
if let Some(bytes) = limits::override_bytes() {
|
||||
let note = crate::i18n::format("prefs.max_file_size_flag", &[("size", &limits::describe(bytes))]);
|
||||
ui_kit::text(ui, ¬e, ui_kit::Text::Hint("max_file_size_flag"));
|
||||
}
|
||||
ui_kit::text(ui, app.tr("prefs.max_file_size_note"), ui_kit::Text::Hint("max_file_size"));
|
||||
}
|
||||
@@ -154,6 +154,37 @@ retain world coordinates. A lost cross-component association refreshed by an old
|
||||
need an explicit relink or refresh when its source returns. Loading never guesses a numerical
|
||||
correction. Association records, coordinate arrays and placements are bounded and checked.
|
||||
|
||||
## Large files
|
||||
|
||||
SolidCraft opens STEP, IGES and the other CAD files it imports up to **512 MB**, and design files
|
||||
up to **256 MB**. A larger file is refused before it is read, and the message says how to raise
|
||||
the limit. In the desktop app you can raise both:
|
||||
|
||||
- **Preferences › General › Largest file to open** sets each limit in MB, from its default up to
|
||||
16 GB (16384 MB). It is kept between runs; Restore Defaults on the General page puts back 512 MB
|
||||
and 256 MB.
|
||||
- **`--max-file-size SIZE`** at launch (`solidcraft --max-file-size 2GB big-assembly.step`) raises
|
||||
both limits for that run only, over the preference, without saving anything. SIZE is a number
|
||||
with MB or GB (`2GB`, `1.5GB`, `1500MB`; 1 GB is 1024 MB), at most 16GB. A size below a default
|
||||
leaves that limit at its default. A size the app can't read stops it from starting, with the
|
||||
reason. `solidcraft-cli` takes the same flag with any command.
|
||||
|
||||
Before you raise them:
|
||||
|
||||
- **Memory:** a file is read whole, and what is built from it is held in memory beside it. Expect
|
||||
several times the file's size in RAM, more for finely detailed parts, and a long open and a slow
|
||||
view for an assembly with hundreds of thousands of faces.
|
||||
- **Saving:** a design keeps the text of a STEP import, compressed, and the design limit applies
|
||||
to the saved file. An import whose compressed text doesn't fit in a design file is refused when
|
||||
it is imported, so it never opens and then fails to save; raise the design file limit too, or
|
||||
open the file with `--max-file-size`, which raises both. Opening that design again needs the
|
||||
same limits.
|
||||
- **Web app:** the browser version keeps 512 MB and 256 MB: a browser tab can't hold larger files.
|
||||
Its Preferences show a note instead of the setting.
|
||||
|
||||
The control channel sets the same preference with `ui.prefs {"max_step_file_mb": 2048,
|
||||
"max_design_file_mb": 1024}`.
|
||||
|
||||
## Design properties
|
||||
|
||||
**File → Design Properties…** (also under **Document Settings** in the Browser, and on the
|
||||
|
||||
@@ -339,6 +339,8 @@ One setting per line, sorted by name. A change that adds a setting adds its own
|
||||
- `logo_accent` (bool, default false: the application bar's logo in shades of the theme's accent instead of the theme's logo colours)
|
||||
- `look_at_anim`
|
||||
- `look_at_speed`
|
||||
- `max_design_file_mb` (default 256): the largest design file opened, in MB, from the default up to 16384 (16 GB) (Preferences › General › Largest file to open, #4086; a `--max-file-size` launch flag overrides both for that run; the web app keeps the defaults and refuses other values; [large files](book/src/guide/files.md#large-files))
|
||||
- `max_step_file_mb` (default 512): the largest STEP or import file opened, in MB, from the default up to 16384 (16 GB) (Preferences › General › Largest file to open, #4086; a `--max-file-size` launch flag overrides both for that run; the web app keeps the defaults and refuses other values; [large files](book/src/guide/files.md#large-files))
|
||||
- `middle_double_click` (`home` (default), `fit`, `off`)
|
||||
- `msaa`
|
||||
- `nav` (`fusion`, `solidworks`, `inventor`, `alias`, `blender`, `tinkercad`, `openscad`, `touchpad`)
|
||||
|
||||
Reference in new issue
Block a user