| 149 | }; |
| 150 | |
| 151 | const 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 | |
| 175 | const restoreFileFromSWCache = async () => { |
| 176 | try { |