aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/server/LocalApi.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/server/LocalApi.ts')
-rw-r--r--src/api/server/LocalApi.ts19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/api/server/LocalApi.ts b/src/api/server/LocalApi.ts
index 71721bb0f..19eacf9ff 100644
--- a/src/api/server/LocalApi.ts
+++ b/src/api/server/LocalApi.ts
@@ -1,5 +1,4 @@
1import { ipcRenderer } from 'electron'; 1import { ipcRenderer } from 'electron';
2import { session } from '@electron/remote';
3import du from 'du'; 2import du from 'du';
4 3
5import { getServicePartitionsDirectory } from '../../helpers/service-helpers'; 4import { getServicePartitionsDirectory } from '../../helpers/service-helpers';
@@ -8,7 +7,7 @@ const debug = require('debug')('Ferdi:LocalApi');
8 7
9export default class LocalApi { 8export default class LocalApi {
10 // Settings 9 // Settings
11 getAppSettings(type: any) { 10 getAppSettings(type: string) {
12 return new Promise(resolve => { 11 return new Promise(resolve => {
13 ipcRenderer.once('appSettings', (_event, resp) => { 12 ipcRenderer.once('appSettings', (_event, resp) => {
14 debug('LocalApi::getAppSettings resolves', resp.type, resp.data); 13 debug('LocalApi::getAppSettings resolves', resp.type, resp.data);
@@ -19,7 +18,7 @@ export default class LocalApi {
19 }); 18 });
20 } 19 }
21 20
22 async updateAppSettings(type: any, data: any) { 21 async updateAppSettings(type: string, data: any) {
23 debug('LocalApi::updateAppSettings resolves', type, data); 22 debug('LocalApi::updateAppSettings resolves', type, data);
24 ipcRenderer.send('updateAppSettings', { 23 ipcRenderer.send('updateAppSettings', {
25 type, 24 type,
@@ -31,7 +30,7 @@ export default class LocalApi {
31 async getAppCacheSize() { 30 async getAppCacheSize() {
32 const partitionsDir = getServicePartitionsDirectory(); 31 const partitionsDir = getServicePartitionsDirectory();
33 return new Promise((resolve, reject) => { 32 return new Promise((resolve, reject) => {
34 du(partitionsDir, (err: Error | null, size?: number | undefined) => { 33 du(partitionsDir, {}, (err: Error | null, size?: number | undefined) => {
35 if (err) reject(err); 34 if (err) reject(err);
36 35
37 debug('LocalApi::getAppCacheSize resolves', size); 36 debug('LocalApi::getAppCacheSize resolves', size);
@@ -41,12 +40,7 @@ export default class LocalApi {
41 } 40 }
42 41
43 async clearCache(serviceId: string | null = null) { 42 async clearCache(serviceId: string | null = null) {
44 const s = serviceId 43 const targetsToClear = {
45 ? session.fromPartition(`persist:service-${serviceId}`)
46 : session.defaultSession;
47
48 debug('LocalApi::clearCache resolves', serviceId || 'clearAppCache');
49 await s.clearStorageData({
50 storages: [ 44 storages: [
51 'appcache', 45 'appcache',
52 'filesystem', 46 'filesystem',
@@ -57,7 +51,8 @@ export default class LocalApi {
57 'cachestorage', 51 'cachestorage',
58 ], 52 ],
59 quotas: ['temporary', 'persistent', 'syncable'], 53 quotas: ['temporary', 'persistent', 'syncable'],
60 }); 54 };
61 return s.clearCache(); 55 ipcRenderer.send('clear-storage-data', { serviceId, targetsToClear });
56 return ipcRenderer.invoke('clear-cache', { serviceId });
62 } 57 }
63} 58}