From 9121360f7b96dd05c729f5b3eaf2a404249f388a Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Wed, 15 Nov 2023 16:48:24 -0500 Subject: [PATCH] osbuild/util/fscache: calculate actual size of files In OSBuild we'll often be operating on sparse files. Let's make the tabulation of the size of files on disk used when determining cache size for pruning consider the actual size of the file usage on disk rather than the size the file reports to be. This means using os.lstat().st_blocks * 512 versus os.lstat().st_size. See https://stackoverflow.com/a/55203604 --- osbuild/util/fscache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osbuild/util/fscache.py b/osbuild/util/fscache.py index 29b3ce90..95860da6 100644 --- a/osbuild/util/fscache.py +++ b/osbuild/util/fscache.py @@ -288,7 +288,7 @@ class FsCache(contextlib.AbstractContextManager, os.PathLike): return sum( os.lstat( os.path.join(path, f) - ).st_size for path, dirs, files in os.walk( + ).st_blocks * 512 for path, dirs, files in os.walk( path_target ) for f in files )