Guest User

Untitled

a guest
May 28th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. export async function updateFile(filePath: string, uri: string) {
  2. const lastUid = localStorage.getItem(`fs-emulation-${filePath}`);
  3. const newUid = String(Math.random());
  4. const lastMd5sum = await sos.offline.cache.getChecksumFile(lastUid, 'md5');
  5. await sos.offline.cache.saveFile(newUid, uri);
  6. const newMd5sum = await sos.offline.cache.getChecksumFile(newUid, 'md5');
  7. if (lastMd5sum !== newMd5sum) {
  8. localStorage.setItem(`fs-emulation-${filePath}`, newUid);
  9. return await sos.offline.cache.loadFile(newUid);
  10. } else {
  11. return await sos.offline.cache.loadFile(lastUid);
  12. }
  13. }
Add Comment
Please, Sign In to add comment