diff options
author | 2020-04-10 19:53:38 +0530 | |
---|---|---|
committer | 2020-04-10 15:23:38 +0100 | |
commit | ab39660497a45e843a3e7ffb6035b5d564ec5ee9 (patch) | |
tree | 0468700c60f703a81b5462c59202a2f152b3dbf0 /src/api/server/LocalApi.js | |
parent | docs: add JakeSteam as a contributor (#556) (diff) | |
download | ferdium-app-ab39660497a45e843a3e7ffb6035b5d564ec5ee9.tar.gz ferdium-app-ab39660497a45e843a3e7ffb6035b5d564ec5ee9.tar.zst ferdium-app-ab39660497a45e843a3e7ffb6035b5d564ec5ee9.zip |
* fix: Clear caches which is not working in Windows 10 (#541)
- In AppStore, the partition directory of allorphanedserviceIds are attempted to be removed during clear cache. However, atleast in Windows, certain files like Cookies, indexedDB and other autogenerated ones during session creation are locked and hence fs.removeDirectory throws an exception. I have added a try catch around this piece of code to avoid uncaught exceptions which causes the spinner to spin indefnitely and prevents execution of further code
- From electron docs - I found that calling session.clearstorage([options]) is a better way to clear session storage data. Hence, in LocalApi.js, we are clearing out all possible storages and quotas of all services and the default session. More info in this link - https://www.electronjs.org/docs/api/session#sesclearstoragedataoptions
* refactor: LocalApi
- refactor clearAppCache and clearCache(serviceId) as suggested by @eandrogehlen
* refactor: #544
- Remove clearAppCache from server/LocalApi.js to use clearCache for clearing both service and application sessions.
* fix: clear_cache
- update function anme in AppStore.js to 'clearCache' instead of 'clearAppCache'. This got missed out during the refactor. Apologies.
Diffstat (limited to 'src/api/server/LocalApi.js')
-rw-r--r-- | src/api/server/LocalApi.js | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/api/server/LocalApi.js b/src/api/server/LocalApi.js index 2d9af416f..cc8035523 100644 --- a/src/api/server/LocalApi.js +++ b/src/api/server/LocalApi.js | |||
@@ -41,17 +41,14 @@ export default class LocalApi { | |||
41 | }); | 41 | }); |
42 | } | 42 | } |
43 | 43 | ||
44 | async clearCache(serviceId) { | 44 | async clearCache(serviceId = null) { |
45 | const s = session.fromPartition(`persist:service-${serviceId}`); | 45 | const s = serviceId ? session.fromPartition(`persist:service-${serviceId}`) : session.defaultSession; |
46 | 46 | ||
47 | debug('LocalApi::clearCache resolves', serviceId); | 47 | debug('LocalApi::clearCache resolves', (serviceId || 'clearAppCache')); |
48 | return s.clearCache(); | 48 | await s.clearStorageData({ |
49 | } | 49 | storages: ['appcache', 'cookies', 'filesystem', 'indexdb', 'localstorage', 'shadercache', 'websql', 'serviceworkers', 'cachestorage'], |
50 | 50 | quotas: ['temporary', 'persistent', 'syncable'], | |
51 | async clearAppCache() { | 51 | }); |
52 | const s = session.defaultSession; | ||
53 | |||
54 | debug('LocalApi::clearCache clearAppCache'); | ||
55 | return s.clearCache(); | 52 | return s.clearCache(); |
56 | } | 53 | } |
57 | } | 54 | } |