diff options
Diffstat (limited to 'src/api/server/LocalApi.js')
-rw-r--r-- | src/api/server/LocalApi.js | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/src/api/server/LocalApi.js b/src/api/server/LocalApi.js deleted file mode 100644 index 644f15b93..000000000 --- a/src/api/server/LocalApi.js +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | import { ipcRenderer } from 'electron'; | ||
2 | import { session } from '@electron/remote'; | ||
3 | import du from 'du'; | ||
4 | |||
5 | import { getServicePartitionsDirectory } from '../../helpers/service-helpers'; | ||
6 | |||
7 | const debug = require('debug')('Ferdi:LocalApi'); | ||
8 | |||
9 | export default class LocalApi { | ||
10 | // Settings | ||
11 | getAppSettings(type) { | ||
12 | return new Promise(resolve => { | ||
13 | ipcRenderer.once('appSettings', (event, resp) => { | ||
14 | debug('LocalApi::getAppSettings resolves', resp.type, resp.data); | ||
15 | resolve(resp); | ||
16 | }); | ||
17 | |||
18 | ipcRenderer.send('getAppSettings', type); | ||
19 | }); | ||
20 | } | ||
21 | |||
22 | async updateAppSettings(type, data) { | ||
23 | debug('LocalApi::updateAppSettings resolves', type, data); | ||
24 | ipcRenderer.send('updateAppSettings', { | ||
25 | type, | ||
26 | data, | ||
27 | }); | ||
28 | } | ||
29 | |||
30 | // Services | ||
31 | async getAppCacheSize() { | ||
32 | const partitionsDir = getServicePartitionsDirectory(); | ||
33 | return new Promise((resolve, reject) => { | ||
34 | du(partitionsDir, (err, size) => { | ||
35 | if (err) reject(err); | ||
36 | |||
37 | debug('LocalApi::getAppCacheSize resolves', size); | ||
38 | resolve(size); | ||
39 | }); | ||
40 | }); | ||
41 | } | ||
42 | |||
43 | async clearCache(serviceId = null) { | ||
44 | const s = serviceId | ||
45 | ? session.fromPartition(`persist:service-${serviceId}`) | ||
46 | : session.defaultSession; | ||
47 | |||
48 | debug('LocalApi::clearCache resolves', serviceId || 'clearAppCache'); | ||
49 | await s.clearStorageData({ | ||
50 | storages: [ | ||
51 | 'appcache', | ||
52 | 'filesystem', | ||
53 | 'indexdb', | ||
54 | 'shadercache', | ||
55 | 'websql', | ||
56 | 'serviceworkers', | ||
57 | 'cachestorage', | ||
58 | ], | ||
59 | quotas: ['temporary', 'persistent', 'syncable'], | ||
60 | }); | ||
61 | return s.clearCache(); | ||
62 | } | ||
63 | } | ||