mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 14:58:05 +08:00
Fix corrupted font resource loading in older documents
This commit is contained in:
committed by
Dennis Kobert
parent
24ca904266
commit
9e32a788ca
@@ -153,6 +153,9 @@ async fn drain_queue(inner: Arc<Mutex<Inner>>) {
|
||||
Mutation::Write { hash, bytes } => {
|
||||
if let Err(error) = write_file(&directory, &hash, &bytes).await {
|
||||
log::error!("OPFS write for {hash} failed: {error:?}");
|
||||
|
||||
// Nothing reached disk, so leaving the hash listed would claim a file that later sessions cannot read
|
||||
inner.lock().unwrap().on_disk.remove(&hash);
|
||||
}
|
||||
}
|
||||
Mutation::Delete { hash } => {
|
||||
|
||||
@@ -258,12 +258,18 @@ pub fn editor_api(_: impl Ctx, #[scope("editor-api")] editor_api: Arc<PlatformEd
|
||||
pub fn resource(_: impl Ctx, hash: ResourceHash, #[scope(editor_api::IDENTIFIER)] editor_api: Arc<PlatformEditorApi>) -> SourceFuture<GPoll<Resource>> {
|
||||
let application_io = editor_api.application_io.clone();
|
||||
Box::pin(async move {
|
||||
// A missing resource degrades to an empty placeholder rather than failing the graph, so a document
|
||||
// whose stored bytes went missing (evicted browser storage, or an interrupted write) still opens
|
||||
let Some(application_io) = application_io else {
|
||||
return GPoll::error("ApplicationIo not available");
|
||||
log::error!("Resource {hash} is unavailable because the platform's application IO is missing");
|
||||
return GPoll::Final(Resource::empty());
|
||||
};
|
||||
match application_io.load_resource(hash).await {
|
||||
Some(resource) => GPoll::Final(resource),
|
||||
None => GPoll::error("resource not found"),
|
||||
None => {
|
||||
log::error!("Resource {hash} was not found in storage");
|
||||
GPoll::Final(Resource::empty())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user