Do not use full filename when FileLocator decides which asset to load

Fixes https://github.com/google/mediapipe/issues/4819

PiperOrigin-RevId: 569506907
This commit is contained in:
Sebastian Schmidt 2023-09-29 09:05:49 -07:00 committed by Copybara-Service
parent 09a51bcdeb
commit d4561fb5c2

View File

@ -52,13 +52,14 @@ export async function createTaskRunner<T extends TaskRunner>(
fileset: WasmFileset, options: TaskRunnerOptions): Promise<T> { fileset: WasmFileset, options: TaskRunnerOptions): Promise<T> {
const fileLocator: FileLocator = { const fileLocator: FileLocator = {
locateFile(file): string { locateFile(file): string {
const wasm = fileset.wasmBinaryPath.toString(); // We currently only use a single .wasm file and a single .data file (for
if (wasm.includes(file)) { // the tasks that have to load assets). We need to revisit how we
return wasm; // initialize the file locator if we ever need to differentiate between
} // diffferent files.
const asset = fileset.assetBinaryPath?.toString(); if (file.endsWith('.wasm')) {
if (asset?.includes(file)) { return fileset.wasmBinaryPath.toString();
return asset; } else if (fileset.assetBinaryPath && file.endsWith('.data')) {
return fileset.assetBinaryPath.toString();
} }
return file; return file;
} }