Fix corrupted font resource loading in older documents

This commit is contained in:
Keavon Chambers
2026-09-15 23:10:50 +02:00
committed by Dennis Kobert
parent 8d2645e20c
commit 71fdf3746a
6 changed files with 300 additions and 115 deletions

View File

@@ -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())
}
}
})
}