fix(web): scripts can open files in browser storage; stored footage isn't reported missing

In the browser editor a .jsx script couldn't open any file, even one the
page holds next to the project: File.open("r") returned false with "File
not found" and File.exists was false. The footage check after File > Open
also marked imported media as missing.

Both asked whether a file exists on the local disk (std::fs), which has no
files on wasm32:
- scripts read files through Session.services but checked existence with
  std::fs (File.open's access check, File.exists, Folder.exists); they now
  ask services.exists / services.is_dir, after the folder check;
- WebServices kept the default exists (std::fs); it now looks in the file
  table.

Desktop and CLI are unchanged (FsServices keeps the std::fs defaults).
Tests: script tests_services (a host with in-memory files), web smoke
step hostFiles (a script reads a stored file, footage check finds stored
media).
This commit is contained in:
rahal
2026-10-15 17:08:01 +01:00
parent 0311bdc34d
commit 228ceb308e
6 changed files with 72 additions and 3 deletions
+5 -2
View File
@@ -380,11 +380,14 @@ fn native_file(_: &JsValue, args: &[JsValue], ctx: &mut Context) -> JsResult<JsV
}
let s = &a.session;
match op.as_str() {
"access" => Ok(json!(check_access(s, &path, false)?.exists())),
// Through the session's services, like the reads: hosts without a file system (the
// browser's file table) answer for their own files.
"access" => Ok(json!(s.services.exists(&check_access(s, &path, false)?.to_string_lossy()))),
"exists" | "isDir" => {
// Unreadable locations report "missing" instead of failing.
let Ok(p) = check_access(s, &path, false) else { return Ok(json!(false)) };
Ok(json!(if op == "exists" { p.exists() } else { p.is_dir() }))
let p = p.to_string_lossy();
Ok(json!(if op == "exists" { s.services.exists(&p) } else { s.services.is_dir(&p) }))
}
"read" | "readBinary" => {
let p = check_access(s, &path, false)?;