catch error when cache access fails
This commit is contained in:
parent
69a193a5c0
commit
8ebb34c56d
|
@ -24,8 +24,16 @@ class DownloadManager {
|
|||
}
|
||||
if (!this.thumbnailObjectURLPromise.get(file.id)) {
|
||||
const downloadPromise = async () => {
|
||||
const thumbnailCache = await caches.open('thumbs');
|
||||
const cacheResp: Response = await thumbnailCache.match(
|
||||
const thumbnailCache = await (async () => {
|
||||
try {
|
||||
return await caches.open('thumbs');
|
||||
} catch (e) {
|
||||
logError(e, 'cache open failed');
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
const cacheResp: Response = await thumbnailCache?.match(
|
||||
file.id.toString()
|
||||
);
|
||||
if (cacheResp) {
|
||||
|
@ -34,7 +42,7 @@ class DownloadManager {
|
|||
const thumb = await this.downloadThumb(token, file);
|
||||
const thumbBlob = new Blob([thumb]);
|
||||
try {
|
||||
await thumbnailCache.put(
|
||||
await thumbnailCache?.put(
|
||||
file.id.toString(),
|
||||
new Response(thumbBlob)
|
||||
);
|
||||
|
|
|
@ -72,13 +72,22 @@ export const setRecoveryKey = (token: string, recoveryKey: RecoveryKey) =>
|
|||
});
|
||||
|
||||
export const logoutUser = async () => {
|
||||
// ignore server logout result as logoutUser can be triggered before sign up or on token expiry
|
||||
await _logout();
|
||||
clearKeys();
|
||||
clearData();
|
||||
await caches.delete('thumbs');
|
||||
await clearFiles();
|
||||
router.push(PAGES.ROOT);
|
||||
try {
|
||||
// ignore server logout result as logoutUser can be triggered before sign up or on token expiry
|
||||
await _logout();
|
||||
clearKeys();
|
||||
clearData();
|
||||
try {
|
||||
await caches.delete('thumbs');
|
||||
} catch (e) {
|
||||
logError(e, 'cache delete failed');
|
||||
// ignore
|
||||
}
|
||||
await clearFiles();
|
||||
router.push(PAGES.ROOT);
|
||||
} catch (e) {
|
||||
logError(e, 'logoutUser failed');
|
||||
}
|
||||
};
|
||||
|
||||
export const clearFiles = async () => {
|
||||
|
|
Loading…
Reference in a new issue