From 99ee597ad3d396ac30cea864c7cd5a5300b555d8 Mon Sep 17 00:00:00 2001 From: Timon Date: Mon, 31 Aug 2026 14:23:29 +0000 Subject: [PATCH] Stop requesting persistent storage --- .../src/application_io/resource/opfs.rs | 32 ++----------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/node-graph/graph-craft/src/application_io/resource/opfs.rs b/node-graph/graph-craft/src/application_io/resource/opfs.rs index 261a172b64..4006480660 100644 --- a/node-graph/graph-craft/src/application_io/resource/opfs.rs +++ b/node-graph/graph-craft/src/application_io/resource/opfs.rs @@ -20,7 +20,6 @@ struct Inner { on_disk: HashSet, queue: VecDeque, worker_active: bool, - persist_requested: bool, } pub struct OpfsResourceStorage { @@ -43,7 +42,6 @@ impl OpfsResourceStorage { on_disk, queue: VecDeque::new(), worker_active: false, - persist_requested: false, })), }) } @@ -130,25 +128,16 @@ fn kick_worker(inner: &Arc>, guard: &mut Inner) { async fn drain_queue(inner: Arc>) { loop { - let (directory, mutation, persist_requested) = { + let (directory, mutation) = { let mut guard = inner.lock().unwrap(); let Some(mutation) = guard.queue.pop_front() else { guard.worker_active = false; return; }; - let persist_requested = matches!(mutation, Mutation::Write { .. }) && !guard.persist_requested; - if persist_requested { - guard.persist_requested = true; - } - - (guard.directory.clone(), mutation, persist_requested) + (guard.directory.clone(), mutation) }; - if persist_requested { - request_persistence().await; - } - match mutation { Mutation::Write { hash, bytes } => { if let Err(error) = write_file(&directory, &hash, &bytes).await { @@ -164,23 +153,6 @@ async fn drain_queue(inner: Arc>) { } } -async fn request_persistence() { - let Some(window) = web_sys::window() else { - log::warn!("OPFS persist() skipped: no window"); - return; - }; - let storage = window.navigator().storage(); - - match storage.persist() { - Ok(promise) => match JsFuture::from(promise).await { - Ok(value) if value.as_bool() == Some(true) => {} - Ok(_) => log::warn!("OPFS persistence was not granted; browser may evict resources under storage pressure"), - Err(error) => log::warn!("OPFS persist() rejected: {error:?}"), - }, - Err(error) => log::warn!("OPFS persist() threw: {error:?}"), - } -} - async fn open_resource_directory(directory_name: &str) -> Result { let storage = web_sys::window().ok_or_else(|| JsValue::from_str("no window"))?.navigator().storage(); let root: FileSystemDirectoryHandle = JsFuture::from(storage.get_directory()).await?.dyn_into()?;