From 7da3ef25ce7b0e817b0a9ed428a4daf6d421cad1 Mon Sep 17 00:00:00 2001 From: shinyobjectz Date: Wed, 18 Nov 2026 19:11:55 -0800 Subject: [PATCH] staticFile finds a web project's public/ A web project keeps its static files in public/. raea's staticFile is /media/x, found in the edit's media/, the project's media/, then its assets/, so a project brought over with its footage in public/ refused it ("vid\\media/orbit.mp4: The system cannot find the path specified", seen on rc7's Windows run) while its sounds played: the sound preload already scans public/. media_path tries public/ last, the edit's own and then the project's, so nothing found today moves. Every engine path a staticFile takes goes through media_path: the render's video and pictures, the bundler's rewrite, CSS url()s, UI materials, model calls, games and the frame's media rows. media_from_the_project: a clip only in the project's public/ is found, the edit's own public/ comes ahead of the project's, and assets/ still comes ahead of public/. --- core/scene/src/media.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/scene/src/media.rs b/core/scene/src/media.rs index 863005159..44567a9bb 100644 --- a/core/scene/src/media.rs +++ b/core/scene/src/media.rs @@ -60,7 +60,8 @@ pub fn project_dir(dir: &Path) -> PathBuf { } /// A media src as a file: a path from staticFile (/media/x: the project's media/, then its assets/, as Bevy's assets -/// folder; the edit's own media/ first when the edit isn't the project's folder), absolute, or relative to the edit. +/// folder; the edit's own media/ first when the edit isn't the project's folder; then public/, where a web project +/// keeps its static files), absolute, or relative to the edit. pub fn media_path(dir: &Path, src: &str) -> PathBuf { if let Some(rest) = src.strip_prefix("/media/") { let project = project_dir(dir); @@ -69,6 +70,10 @@ pub fn media_path(dir: &Path, src: &str) -> PathBuf { tried.push(project.join("media")); } tried.push(project.join("assets")); + tried.push(dir.join("public")); + if project != dir { + tried.push(project.join("public")); + } if let Some(p) = tried.iter().map(|d| d.join(rest)).find(|p| p.exists()) { return p; } @@ -103,6 +108,16 @@ mod tests { assert_eq!(media_path(&src, "/media/c.png"), src.join("media/c.png")); // missing: where it was always looked for assert_eq!(media_path(&src, "/media/d.png"), src.join("media/d.png")); + // a web project's public/, after media/ and assets/: the edit's own, then the project's + for d in [&root.join("public"), &src.join("public")] { + std::fs::create_dir_all(d).unwrap(); + } + for f in ["public/f.mp4", "src/public/g.mp4", "public/g.mp4", "public/a.png"] { + std::fs::write(root.join(f), "").unwrap(); + } + assert_eq!(media_path(&src, "/media/f.mp4"), root.join("public/f.mp4")); + assert_eq!(media_path(&src, "/media/g.mp4"), src.join("public/g.mp4")); + assert_eq!(media_path(&src, "/media/a.png"), root.join("assets/a.png"), "assets/ still ahead of public/"); // no space.json above: the edit's folder is the project, its assets/ after its media/ let plain = root.join("plain"); std::fs::create_dir_all(plain.join("assets")).unwrap();