From dd6a156d7c9de9824940d823af305ee7a413fea5 Mon Sep 17 00:00:00 2001 From: jessopb <36554050+jessopb@users.noreply.github.com> Date: Sun, 5 Jun 2022 12:10:12 -0400 Subject: [PATCH] fix diskspace windows bytes (#7601) --- flow-typed/Settings.js | 4 ++-- ui/component/appStorageVisualization/view.jsx | 4 ++-- ui/component/hostingSplash/view.jsx | 4 ++-- ui/component/settingViewHosting/view.jsx | 4 ++-- ui/util/diskspace.js | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/flow-typed/Settings.js b/flow-typed/Settings.js index f98fa2d99..2c1b37f6c 100644 --- a/flow-typed/Settings.js +++ b/flow-typed/Settings.js @@ -8,6 +8,6 @@ declare type WalletServerDetails = { }; declare type DiskSpace = { - total: string, - free: string, + total: number, + free: number, }; diff --git a/ui/component/appStorageVisualization/view.jsx b/ui/component/appStorageVisualization/view.jsx index c8d40cbe9..51c508585 100644 --- a/ui/component/appStorageVisualization/view.jsx +++ b/ui/component/appStorageVisualization/view.jsx @@ -25,8 +25,8 @@ function StorageViz(props: Props) { ); } - const totalMB = diskSpace && Math.floor(Number(diskSpace.total) / 1024); - const freeMB = diskSpace && Math.floor(Number(diskSpace.free) / 1024); + const totalMB = diskSpace && Math.floor(diskSpace.total / 1024); + const freeMB = diskSpace && Math.floor(diskSpace.free / 1024); const otherMB = totalMB - (freeMB + viewBlobSpace + autoBlobSpace + privateBlobSpace); const autoFree = autoHostingLimit - autoBlobSpace; const viewFree = viewHostingLimit > 0 ? viewHostingLimit - viewBlobSpace : freeMB - autoFree; diff --git a/ui/component/hostingSplash/view.jsx b/ui/component/hostingSplash/view.jsx index efe9472a1..d26b83a94 100644 --- a/ui/component/hostingSplash/view.jsx +++ b/ui/component/hostingSplash/view.jsx @@ -41,8 +41,8 @@ function HostingSplash(props: Props) { handleDone, } = props; - const totalMB = diskSpace && Math.floor(Number(diskSpace.total) / 1024); - const freeMB = diskSpace && Math.floor(Number(diskSpace.free) / 1024); + const totalMB = diskSpace && Math.floor(diskSpace.total / 1024); + const freeMB = diskSpace && Math.floor(diskSpace.free / 1024); const blobSpaceUsed = viewBlobSpace + autoBlobSpace; const [hostingChoice, setHostingChoice] = React.useState('MANAGED'); diff --git a/ui/component/settingViewHosting/view.jsx b/ui/component/settingViewHosting/view.jsx index ff0a13050..e82b3b2cf 100644 --- a/ui/component/settingViewHosting/view.jsx +++ b/ui/component/settingViewHosting/view.jsx @@ -41,8 +41,8 @@ function SettingViewHosting(props: Props) { } = props; // best effort to recommend a hosting amount default for the user - const totalMB = diskSpace && Math.floor(Number(diskSpace.total) / 1024); - const freeMB = diskSpace && Math.floor(Number(diskSpace.free) / 1024); + const totalMB = diskSpace && Math.floor(diskSpace.total / 1024); + const freeMB = diskSpace && Math.floor(diskSpace.free / 1024); const getGB = (val) => (Number(val) / 1024).toFixed(2); const recommendedSpace = freeMB > totalMB * TWENTY_PERCENT // plenty of space? diff --git a/ui/util/diskspace.js b/ui/util/diskspace.js index ed9508bea..11c2b232e 100644 --- a/ui/util/diskspace.js +++ b/ui/util/diskspace.js @@ -14,8 +14,8 @@ export const diskSpaceLinux = (path) => { // C:\ 185087700 120552556 64535144 66% /mnt/c const dfResult = stdout.split('\n')[1].split(/\s+/); resolve({ - total: dfResult[1], - free: dfResult[3], + total: Number(dfResult[1]), + free: Number(dfResult[3]), }); }); }); @@ -57,8 +57,8 @@ export const diskSpaceWindows = (path) => { const [drive, freeSpace, totalSize] = driveLine.split(' ').filter((x) => x); resolve({ - total: totalSize, - free: freeSpace, + total: Math.floor(Number(totalSize) / 1024), + free: Math.floor(Number(freeSpace) / 1024), }); }); });