Split accessing cache instance and processing data #3747
| @@ -115,6 +115,7 @@ class DiskCache { | ||
| 115 | 115 | * @returns {Promise<void>} |
| 116 | 116 | */ |
| 117 | 117 | async verify(directoriesList) { |
| 118 | + try { | |
| 118 | 119 | if (!useDiskCache) { |
| 119 | 120 | return; |
| 120 | 121 | } |
| @@ -134,6 +135,9 @@ class DiskCache { | ||
| 134 | 135 | await cache.removeItem(key); |
| 135 | 136 | } |
| 136 | 137 | } |
| 138 | + } catch (error) { | |
| 139 | + console.error('Error while verifying disk cache:', error); | |
| 140 | + } | |
| 137 | 141 | } |
| 138 | 142 | |
| 139 | 143 | dispose() { |
| @@ -172,7 +176,8 @@ async function readCharacterData(inputFile, inputFormat = 'png') { | ||
| 172 | 176 | } |
| 173 | 177 | if (useDiskCache) { |
| 174 | 178 | try { |
| 175 | 179 | const cachedDatacache = await diskCache.instance().then(i => i.getItem(cacheKey)); |
| 180 | + const cachedData = await cache.getItem(cacheKey); | |
| 176 | 181 | if (cachedData) { |
| 177 | 182 | return cachedData; |
| 178 | 183 | } |
| @@ -185,7 +190,8 @@ async function readCharacterData(inputFile, inputFormat = 'png') { | ||
| 185 | 190 | !isAndroid && memoryCache.set(cacheKey, result); |
| 186 | 191 | if (useDiskCache) { |
| 187 | 192 | try { |
| 188 | - await diskCache.instance().then(i => i.setItem(cacheKey, result)); | |
| 193 | + const cache = await diskCache.instance(); | |
| 194 | + await cache.setItem(cacheKey, result); | |
| 189 | 195 | } catch (error) { |
| 190 | 196 | console.warn('Error while writing to disk cache:', error); |
| 191 | 197 | } |