MCPcopy Create free account
hub / github.com/GoogleChrome/samples / restoreFileFromOPFS

Function restoreFileFromOPFS

mediapipe-llm/script.js:151–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149};
150
151const restoreFileFromOPFS = async () => {
152 try {
153 performance.mark('start-opfs-restore');
154 const root = await navigator.storage.getDirectory();
155 const handle = await root.getFileHandle('model.bin');
156 const file = await handle.getFile();
157 performance.mark('end-opfs-restore');
158 const mark = performance.measure(
159 'opfs-restore',
160 'start-opfs-restore',
161 'end-opfs-restore'
162 );
163 console.log(
164 'Cached model file found in OPFS.',
165 mark.name,
166 mark.duration.toFixed(2)
167 );
168 modelBlobURL = URL.createObjectURL(file);
169 return 'Origin Private File System';
170 } catch (err) {
171 throw err;
172 }
173};
174
175const restoreFileFromSWCache = async () => {
176 try {

Callers 1

initFunction · 0.85

Calls 1

logMethod · 0.45

Tested by

no test coverage detected