Skip to content

Commit 44a9821

Browse files
mezantropefa2d19
authored andcommitted
refactor(EntryPoint): updated count_free_space to use statvfs
1 parent 6b3f754 commit 44a9821

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mac_cleanup/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
from os import statvfs
12
from pathlib import Path
23

34
from mac_cleanup.config import Config
45
from mac_cleanup.console import console, print_panel
56
from mac_cleanup.core import _Collector
67
from mac_cleanup.error_handling import catch_exception
78
from mac_cleanup.parser import args
8-
from mac_cleanup.utils import bytes_to_human, cmd
9+
from mac_cleanup.utils import bytes_to_human
910

1011

1112
class EntryPoint:
@@ -16,7 +17,8 @@ class EntryPoint:
1617
def count_free_space() -> float:
1718
"""Get current free space."""
1819

19-
return float(cmd("df / | tail -1 | awk '{print $4}'"))
20+
s_fs = statvfs("/")
21+
return float(s_fs.f_bavail * s_fs.f_frsize / s_fs.f_bsize)
2022

2123
def cleanup(self) -> None:
2224
"""Launch cleanup and print results."""

0 commit comments

Comments
 (0)