aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2018-01-03 23:46:54 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2018-01-03 23:46:54 +0100
commitbe801ff55d765e519f58a34d9854fb464a1ff77e (patch)
tree48c7972577c6b73cb5ca0d1947c5a8b198b98614 /src/api
parentFix lint issues (diff)
downloadferdium-app-be801ff55d765e519f58a34d9854fb464a1ff77e.tar.gz
ferdium-app-be801ff55d765e519f58a34d9854fb464a1ff77e.tar.zst
ferdium-app-be801ff55d765e519f58a34d9854fb464a1ff77e.zip
feat(App): Add option to clear app cache (@dannyqiu)
Diffstat (limited to 'src/api')
-rw-r--r--src/api/LocalApi.js4
-rw-r--r--src/api/server/LocalApi.js24
-rw-r--r--src/api/server/ServerApi.js4
3 files changed, 28 insertions, 4 deletions
diff --git a/src/api/LocalApi.js b/src/api/LocalApi.js
index d52e9cd10..3f84f8a0b 100644
--- a/src/api/LocalApi.js
+++ b/src/api/LocalApi.js
@@ -16,6 +16,10 @@ export default class LocalApi {
16 return this.local.removeKey(key); 16 return this.local.removeKey(key);
17 } 17 }
18 18
19 getAppCacheSize() {
20 return this.local.getAppCacheSize();
21 }
22
19 clearAppCache() { 23 clearAppCache() {
20 return this.local.clearAppCache(); 24 return this.local.clearAppCache();
21 } 25 }
diff --git a/src/api/server/LocalApi.js b/src/api/server/LocalApi.js
index d2ce0c9de..e95d750ac 100644
--- a/src/api/server/LocalApi.js
+++ b/src/api/server/LocalApi.js
@@ -1,4 +1,7 @@
1import { remote } from 'electron'; 1import { remote } from 'electron';
2import du from 'du';
3
4import { getServicePartitionsDirectory } from '../../helpers/service-helpers.js';
2 5
3const { session } = remote; 6const { session } = remote;
4 7
@@ -36,14 +39,29 @@ export default class LocalApi {
36 } 39 }
37 40
38 // Services 41 // Services
42 async getAppCacheSize() {
43 const partitionsDir = getServicePartitionsDirectory();
44 return new Promise((resolve, reject) => {
45 du(partitionsDir, (err, size) => {
46 if (err) reject(err);
47
48 console.debug('LocalApi::getAppCacheSize resolves', size);
49 resolve(size);
50 });
51 });
52 }
53
39 async clearCache(serviceId) { 54 async clearCache(serviceId) {
40 console.debug(`Clearing cache for persist:service-${serviceId}`);
41 const s = session.fromPartition(`persist:service-${serviceId}`); 55 const s = session.fromPartition(`persist:service-${serviceId}`);
42 await new Promise(resolve => s.clearCache(resolve)); 56
57 console.debug('LocalApi::clearCache resolves', serviceId);
58 return new Promise(resolve => s.clearCache(resolve));
43 } 59 }
44 60
45 async clearAppCache() { 61 async clearAppCache() {
46 const s = session.defaultSession; 62 const s = session.defaultSession;
47 await new Promise(resolve => s.clearCache(resolve)); 63
64 console.debug('LocalApi::clearCache clearAppCache');
65 return new Promise(resolve => s.clearCache(resolve));
48 } 66 }
49} 67}
diff --git a/src/api/server/ServerApi.js b/src/api/server/ServerApi.js
index 3daa2d8b6..d75d2e559 100644
--- a/src/api/server/ServerApi.js
+++ b/src/api/server/ServerApi.js
@@ -213,7 +213,9 @@ export default class ServerApi {
213 throw request; 213 throw request;
214 } 214 }
215 const data = await request.json(); 215 const data = await request.json();
216 await removeServicePartitionDirectory(id); 216
217 removeServicePartitionDirectory(id, true);
218
217 console.debug('ServerApi::deleteService resolves', data); 219 console.debug('ServerApi::deleteService resolves', data);
218 return data; 220 return data;
219 } 221 }