From: Daan De Meyer Date: Tue, 21 Jan 2025 22:47:57 +0000 (+0100) Subject: Move uid check back to have_cache() X-Git-Tag: v25~12^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b4c4a4ac8ca6bc34b8dd98474597a8596299aa8;p=thirdparty%2Fmkosi.git Move uid check back to have_cache() We moved this to reuse_cache() before the introduction of mkosi-sandbox because we would change uids during execution. Now that we don't do that anymore, we can move the check back to have_cache(). --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 10ace4d6c..2c072df51 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -3068,6 +3068,12 @@ def have_cache(config: Config) -> bool: logging.debug(f"{final} does not exist, not reusing cached images") return False + if (uid := final.stat().st_uid) != os.getuid(): + logging.debug( + f"{final} uid ({uid}) does not match user uid ({os.getuid()}), not reusing cached images" + ) + return False + if need_build_overlay(config) and not build.exists(): logging.debug(f"{build} does not exist, not reusing cached images") return False @@ -3102,9 +3108,6 @@ def reuse_cache(context: Context) -> bool: final, build, _ = cache_tree_paths(context.config) - if final.stat().st_uid != os.getuid(): - return False - with complete_step("Copying cached trees"): copy_tree( final,