From d4a92d360c6e008d303446e6188cc063d58d0f47 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Sat, 25 Oct 2025 20:33:11 +0200 Subject: [PATCH] fix: Correctly remove mismatching manifest file This fixes a bug introduced in commit c7c0837a ("Refactor main primary storage backend code into storage/primary"). --- src/ccache/ccache.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ccache/ccache.cpp b/src/ccache/ccache.cpp index 6e503d31..e442707d 100644 --- a/src/ccache/ccache.cpp +++ b/src/ccache/ccache.cpp @@ -2964,6 +2964,11 @@ do_cache_compilation(Context& ctx) ASSERT(result_key); if (result_key_from_manifest && result_key_from_manifest != result_key) { + // manifest_path is guaranteed to be set when calculate_result_name + // returns a non-nullopt result in direct mode, i.e. when + // result_name_from_manifest is set. + ASSERT(manifest_key); + // The hash from manifest differs from the hash of the preprocessor // output. This could be because: // @@ -2979,7 +2984,7 @@ do_cache_compilation(Context& ctx) LOG_RAW("Hash from manifest doesn't match preprocessor output"); LOG_RAW("Likely reason: different CCACHE_BASEDIRs used"); LOG_RAW("Removing manifest as a safety measure"); - ctx.storage.remove(*result_key, core::CacheEntryType::result); + ctx.storage.remove(*manifest_key, core::CacheEntryType::manifest); put_result_in_manifest = true; } -- 2.47.3