aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
authorLibravatar Mahadevan Sreenivasan <mahadevan_sv@yahoo.com>2020-04-10 19:53:38 +0530
committerLibravatar GitHub <noreply@github.com>2020-04-10 15:23:38 +0100
commitab39660497a45e843a3e7ffb6035b5d564ec5ee9 (patch)
tree0468700c60f703a81b5462c59202a2f152b3dbf0 /src/api
parentdocs: add JakeSteam as a contributor (#556) (diff)
downloadferdium-app-ab39660497a45e843a3e7ffb6035b5d564ec5ee9.tar.gz
ferdium-app-ab39660497a45e843a3e7ffb6035b5d564ec5ee9.tar.zst
ferdium-app-ab39660497a45e843a3e7ffb6035b5d564ec5ee9.zip
Fix cache clearing not working in Windows 10 (#541) (#544)
* 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')
-rw-r--r--src/api/LocalApi.js4
-rw-r--r--src/api/server/LocalApi.js17
2 files changed, 9 insertions, 12 deletions
diff --git a/src/api/LocalApi.js b/src/api/LocalApi.js
index e2a46874a..ccdedd3f5 100644
--- a/src/api/LocalApi.js
+++ b/src/api/LocalApi.js
@@ -16,7 +16,7 @@ export default class LocalApi {
16 return this.local.getAppCacheSize(); 16 return this.local.getAppCacheSize();
17 } 17 }
18 18
19 clearAppCache() { 19 clearCache() {
20 return this.local.clearAppCache(); 20 return this.local.clearCache();
21 } 21 }
22} 22}
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}