mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-31 21:56:50 -06:00
Integration: next's file reads go through the checked readers
main's file guard requires reads to pass the automation roots. Loading styles from a path, the recent-files check and sniffing a dropped file without an extension read with std::fs directly; they use the engine's io module.
This commit is contained in:
@@ -82,7 +82,7 @@ impl Kind {
|
||||
fn source(p: &Value, id: &str) -> Result<Document> {
|
||||
let (bytes, name) = match (str_param(p, "path"), str_param(p, "base64")) {
|
||||
(_, Some(b)) => (super::file::base64_decode(b), str_param(p, "name").unwrap_or("").to_string()),
|
||||
(Some(path), None) => (std::fs::read(path).map_err(|e| bad(id, format!("{path}: {e}")))?, path.to_string()),
|
||||
(Some(path), None) => (crate::io::read_file(path).map_err(|e| bad(id, e))?, path.to_string()),
|
||||
_ => return Err(bad(id, "give `path` or `base64`")),
|
||||
};
|
||||
if name.to_lowercase().ends_with(".idml") {
|
||||
|
||||
@@ -1005,7 +1005,7 @@ fn recent_file_stat_at(ctx: &egui::Context, path: &str, now: f64) -> RecentStat
|
||||
{
|
||||
return st;
|
||||
}
|
||||
let meta = std::fs::metadata(path).ok().filter(std::fs::Metadata::is_file);
|
||||
let meta = designcraft_engine::io::metadata(path).ok().filter(designcraft_engine::io::Metadata::is_file);
|
||||
let st = RecentStat { exists: meta.is_some(), modified: meta.and_then(|m| m.modified().ok()), checked: now };
|
||||
ctx.data_mut(|d| d.insert_temp(key, st.clone()));
|
||||
st
|
||||
|
||||
@@ -1298,7 +1298,7 @@ impl DesignApp {
|
||||
return self.run("swatch.load", json!({"path": path}));
|
||||
}
|
||||
let document = opens_as_document(path)
|
||||
|| (std::path::Path::new(path).extension().is_none() && std::fs::read(path).is_ok_and(|b| designcraft_engine::cmd::is_document(&b)));
|
||||
|| (std::path::Path::new(path).extension().is_none() && designcraft_engine::io::read(path).is_ok_and(|b| designcraft_engine::cmd::is_document(&b)));
|
||||
if document {
|
||||
return self.open_file("file.open", json!({"path": path}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user