Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export async function updateFile(filePath: string, uri: string) {
- const lastUid = localStorage.getItem(`fs-emulation-${filePath}`);
- const newUid = String(Math.random());
- const lastMd5sum = await sos.offline.cache.getChecksumFile(lastUid, 'md5');
- await sos.offline.cache.saveFile(newUid, uri);
- const newMd5sum = await sos.offline.cache.getChecksumFile(newUid, 'md5');
- if (lastMd5sum !== newMd5sum) {
- localStorage.setItem(`fs-emulation-${filePath}`, newUid);
- return await sos.offline.cache.loadFile(newUid);
- } else {
- return await sos.offline.cache.loadFile(lastUid);
- }
- }
Add Comment
Please, Sign In to add comment