Web disk cache: handle the Matte kind (mattes/ folder)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
4acea86d4f
commit
925760c9c8
@@ -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
|
// ends in a checksum) and read the layer buffers they prefetch; the page lists, reads and
|
||||||
// deletes.
|
// deletes.
|
||||||
const CACHE_ROOT = "effectcraft-cache";
|
const CACHE_ROOT = "effectcraft-cache";
|
||||||
const CACHE_KINDS = ["frames", "layers"];
|
const CACHE_KINDS = ["frames", "layers", "mattes"];
|
||||||
const cacheDirHandles = {};
|
const cacheDirHandles = {};
|
||||||
|
|
||||||
async function cacheDir(kind = "frames") {
|
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`).
|
/// The folder and file name of an entry name (`layers/<hex>.ecc` or `<hex>.ecc`).
|
||||||
async function entryDir(name) {
|
async function entryDir(name) {
|
||||||
if (name.startsWith("layers/")) return [await cacheDir("layers"), name.slice(7)];
|
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];
|
return [await cacheDir("frames"), name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
pub(crate) fn name_of(kind: Kind, key: u128) -> String {
|
||||||
match kind {
|
match kind {
|
||||||
Kind::Frame => disk_cache::entry_name(key),
|
Kind::Frame => disk_cache::entry_name(key),
|
||||||
Kind::Layer => format!("layers/{}", 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)> {
|
fn parse_name(name: &str) -> Option<(Kind, u128)> {
|
||||||
match name.strip_prefix("layers/") {
|
if let Some(n) = name.strip_prefix("layers/") {
|
||||||
Some(n) => Some((Kind::Layer, disk_cache::parse_entry_name(n)?)),
|
return 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("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
|
/// Layer entries (32 hex digits) a frame worker should read before its next frame: recent
|
||||||
|
|||||||
Reference in New Issue
Block a user