mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-12 05:22:51 +00:00
address review: text file limit 1 GiB (covers a 256^3 .cube); a LUT or OCIO file that is refused is logged
This commit is contained in:
@@ -284,7 +284,10 @@ pub fn load_file(src: &str) -> Option<Arc<FileXform>> {
|
||||
parse_file(src, "")
|
||||
} else {
|
||||
let ext = std::path::Path::new(src_t).extension().and_then(std::ffi::OsStr::to_str).unwrap_or("");
|
||||
crate::utility::read_text_file(std::path::Path::new(src_t)).ok().and_then(|t| parse_file(&t, ext))
|
||||
crate::utility::read_text_file(std::path::Path::new(src_t))
|
||||
.map_err(|e| log::warn!("OCIO file transform not loaded: {e}"))
|
||||
.ok()
|
||||
.and_then(|t| parse_file(&t, ext))
|
||||
}
|
||||
.map(Arc::new);
|
||||
if let Ok(mut m) = cache.lock() {
|
||||
|
||||
@@ -346,15 +346,21 @@ pub fn load_lut(src: &str) -> Option<Arc<Lut>> {
|
||||
return v.clone();
|
||||
}
|
||||
let inline = src.contains('\n') || src.contains("LUT_");
|
||||
let parsed = if inline { parse_cube(src) } else { read_text_file(Path::new(src.trim())).ok().and_then(|t| parse_cube(&t)) }.map(Arc::new);
|
||||
let parsed = if inline {
|
||||
parse_cube(src)
|
||||
} else {
|
||||
read_text_file(Path::new(src.trim())).map_err(|e| log::warn!("LUT not loaded: {e}")).ok().and_then(|t| parse_cube(&t))
|
||||
}
|
||||
.map(Arc::new);
|
||||
if let Ok(mut m) = cache.lock() {
|
||||
m.insert(src.to_string(), parsed.clone());
|
||||
}
|
||||
parsed
|
||||
}
|
||||
|
||||
/// Largest text file an effect reads (a LUT, an OCIO config, Mocha shape data).
|
||||
const MAX_TEXT_FILE_BYTES: u64 = 256 << 20;
|
||||
/// Largest text file an effect reads (a LUT, an OCIO config, Mocha shape data): 1 GiB, over the
|
||||
/// ~0.45 GB a 256³ `.cube` takes with six decimals, so no supported LUT is refused.
|
||||
const MAX_TEXT_FILE_BYTES: u64 = 1 << 30;
|
||||
|
||||
/// A text file an effect parameter or a saved project names: only a regular file, and only up to
|
||||
/// [`MAX_TEXT_FILE_BYTES`] (`/dev/zero` or a FIFO would never end).
|
||||
|
||||
Reference in New Issue
Block a user