From e8fb7ef981f14dd85812e81586e653a9e6d41a32 Mon Sep 17 00:00:00 2001 From: heliguy Date: Wed, 29 Nov 2023 03:29:41 -0500 Subject: [PATCH] Changes to file size and file size formatting func Make the human readable response use powers of 1000 instead of 1024 Add a flat rate of 4000 to any returned file size to attempt to get a bit more accurate to the real file size --- src/common.py | 7 ++++--- src/window.py | 3 --- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/common.py b/src/common.py index cdb1749..82623a9 100644 --- a/src/common.py +++ b/src/common.py @@ -1,4 +1,4 @@ -from gi.repository import GLib, Gtk, Adw #, Gdk, Gio +from gi.repository import GLib, Gtk, Adw, Gio #, Gdk import os import subprocess import pathlib @@ -28,7 +28,7 @@ class myUtils: return self.getSizeFormat(self.getDirectorySize(path)) def getSizeFormat(self, b): - factor = 1024 + factor = 1000 suffix = "B" for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: if b < factor: @@ -61,7 +61,8 @@ class myUtils: return 0 if total == 0: return 0 - return total + 1500 + # Adding 4000 seems to make it more accurate to whatever data we can't scan from within the sandbox + return total + 4000 def findAppIcon(self, app_id): icon_theme = Gtk.IconTheme.new() diff --git a/src/window.py b/src/window.py index b3fb5f9..24c354e 100644 --- a/src/window.py +++ b/src/window.py @@ -716,6 +716,3 @@ class WarehouseWindow(Adw.ApplicationWindow): if Config.DEVEL: self.add_css_class("devel") - - -