From 68a04f90633346cf48aa01ae44c6757c47c37965 Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Tue, 12 Oct 2021 17:42:17 +0200 Subject: chore: replace deprecated du with fast-folder-size (#2050) --- src/api/server/LocalApi.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src') 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 @@ +import { ExecException } from 'child_process'; import { ipcRenderer } from 'electron'; -import du from 'du'; +import fastFolderSize from 'fast-folder-size'; import { getServicePartitionsDirectory } from '../../helpers/service-helpers'; @@ -29,13 +30,19 @@ export default class LocalApi { // Services async getAppCacheSize() { const partitionsDir = getServicePartitionsDirectory(); + return new Promise((resolve, reject) => { - du(partitionsDir, {}, (err: Error | null, size?: number | undefined) => { - if (err) reject(err); + fastFolderSize( + partitionsDir, + (err: ExecException | null, bytes: number | undefined) => { + if (err) { + reject(err); + } - debug('LocalApi::getAppCacheSize resolves', size); - resolve(size); - }); + debug('LocalApi::getAppCacheSize resolves', bytes); + resolve(bytes); + }, + ); }); } -- cgit v1.2.3-70-g09d2