Web disk cache: handle the Matte kind (mattes/ folder)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
vangel76
2026-10-12 19:08:21 +02:00
co-authored by Claude Sonnet 5.5
parent 4acea86d4f
commit 925760c9c8
2 changed files with 10 additions and 5 deletions
+2 -1
View File
@@ -404,7 +404,7 @@ export function frameWorkerStart(base, onMessage, gpu) {
// ends in a checksum) and read the layer buffers they prefetch; the page lists, reads and
// deletes.
const CACHE_ROOT = "effectcraft-cache";
const CACHE_KINDS = ["frames", "layers"];
const CACHE_KINDS = ["frames", "layers", "mattes"];
const cacheDirHandles = {};
async function cacheDir(kind = "frames") {
@@ -419,6 +419,7 @@ async function cacheDir(kind = "frames") {
/// The folder and file name of an entry name (`layers/<hex>.ecc` or `<hex>.ecc`).
async function entryDir(name) {
if (name.startsWith("layers/")) return [await cacheDir("layers"), name.slice(7)];
if (name.startsWith("mattes/")) return [await cacheDir("mattes"), name.slice(7)];
return [await cacheDir("frames"), name];
}
+8 -4
View File
@@ -105,19 +105,23 @@ pub fn init() {
});
}
/// An entry's name in `js/host.js`'s cache folders (`layers/` for layer buffers).
/// An entry's name in `js/host.js`'s cache folders (`layers/` for layer buffers, `mattes/` for segmentations).
pub(crate) fn name_of(kind: Kind, key: u128) -> String {
match kind {
Kind::Frame => disk_cache::entry_name(key),
Kind::Layer => format!("layers/{}", disk_cache::entry_name(key)),
Kind::Matte => format!("mattes/{}", disk_cache::entry_name(key)),
}
}
fn parse_name(name: &str) -> Option<(Kind, u128)> {
match name.strip_prefix("layers/") {
Some(n) => Some((Kind::Layer, disk_cache::parse_entry_name(n)?)),
None => Some((Kind::Frame, disk_cache::parse_entry_name(name)?)),
if let Some(n) = name.strip_prefix("layers/") {
return Some((Kind::Layer, disk_cache::parse_entry_name(n)?));
}
if let Some(n) = name.strip_prefix("mattes/") {
return Some((Kind::Matte, disk_cache::parse_entry_name(n)?));
}
Some((Kind::Frame, disk_cache::parse_entry_name(name)?))
}
/// Layer entries (32 hex digits) a frame worker should read before its next frame: recent