diff options
author | 2021-10-12 17:42:17 +0200 | |
---|---|---|
committer | 2021-10-12 17:42:17 +0200 | |
commit | 68a04f90633346cf48aa01ae44c6757c47c37965 (patch) | |
tree | f5ad7f927e9b9e391abdda8f72fc9cc375b8c427 /src | |
parent | 5.6.3-nightly.31 [skip ci] (diff) | |
download | ferdium-app-68a04f90633346cf48aa01ae44c6757c47c37965.tar.gz ferdium-app-68a04f90633346cf48aa01ae44c6757c47c37965.tar.zst ferdium-app-68a04f90633346cf48aa01ae44c6757c47c37965.zip |
chore: replace deprecated du with fast-folder-size (#2050)
Diffstat (limited to 'src')
-rw-r--r-- | src/api/server/LocalApi.ts | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/api/server/LocalApi.ts b/src/api/server/LocalApi.ts index 19eacf9ff..1a46aaefe 100644 --- a/src/api/server/LocalApi.ts +++ b/src/api/server/LocalApi.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { ExecException } from 'child_process'; | ||
1 | import { ipcRenderer } from 'electron'; | 2 | import { ipcRenderer } from 'electron'; |
2 | import du from 'du'; | 3 | import fastFolderSize from 'fast-folder-size'; |
3 | 4 | ||
4 | import { getServicePartitionsDirectory } from '../../helpers/service-helpers'; | 5 | import { getServicePartitionsDirectory } from '../../helpers/service-helpers'; |
5 | 6 | ||
@@ -29,13 +30,19 @@ export default class LocalApi { | |||
29 | // Services | 30 | // Services |
30 | async getAppCacheSize() { | 31 | async getAppCacheSize() { |
31 | const partitionsDir = getServicePartitionsDirectory(); | 32 | const partitionsDir = getServicePartitionsDirectory(); |
33 | |||
32 | return new Promise((resolve, reject) => { | 34 | return new Promise((resolve, reject) => { |
33 | du(partitionsDir, {}, (err: Error | null, size?: number | undefined) => { | 35 | fastFolderSize( |
34 | if (err) reject(err); | 36 | partitionsDir, |
37 | (err: ExecException | null, bytes: number | undefined) => { | ||
38 | if (err) { | ||
39 | reject(err); | ||
40 | } | ||
35 | 41 | ||
36 | debug('LocalApi::getAppCacheSize resolves', size); | 42 | debug('LocalApi::getAppCacheSize resolves', bytes); |
37 | resolve(size); | 43 | resolve(bytes); |
38 | }); | 44 | }, |
45 | ); | ||
39 | }); | 46 | }); |
40 | } | 47 | } |
41 | 48 | ||