]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat: Log errors and size changes when recompressing cache files
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 26 Oct 2025 15:04:53 +0000 (16:04 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 26 Oct 2025 17:24:22 +0000 (18:24 +0100)
src/ccache/core/mainoptions.cpp
src/ccache/storage/local/localstorage.cpp

index 647606a4c3aa7f8e8e8264e55ac1a6b0a1bcca57..d00b38b8b4b939396d81287e68227f4a8251422b 100644 (file)
@@ -358,9 +358,17 @@ trim_dir(const std::string& dir,
         try {
           auto new_stat = recompressor.recompress(
             file, *recompress_level, core::FileRecompressor::KeepAtime::yes);
-          file = std::move(new_stat); // Remember new size, if any.
-        } catch (core::Error&) {
-          // Ignore for now.
+          auto old_size = file.size();
+          auto new_size = new_stat.size();
+          if (new_size != old_size) {
+            LOG("Recompressed {} from {} to {} bytes",
+                file.path(),
+                old_size,
+                new_size);
+            file = std::move(new_stat); // Remember for sum calculation later
+          }
+        } catch (core::Error& e) {
+          LOG("Error when recompressing {}: {}", file.path(), e.what());
           incompressible_size += file.size_on_disk();
         }
       });
index 09dba0955dce1bbe682272c075a441e8b7a43ad0..ce2aaeb4f06c3fca0af88eff988468d0b569911d 100644 (file)
@@ -910,6 +910,14 @@ LocalStorage::recompress(const std::optional<int8_t> level,
                 try {
                   DirEntry new_dir_entry = recompressor.recompress(
                     file, level, core::FileRecompressor::KeepAtime::no);
+                  auto old_size = file.size();
+                  auto new_size = new_dir_entry.size();
+                  // LOG_RAW+fmt::format instead of LOG due to GCC 12.3 bug
+                  // #109241
+                  LOG_RAW(fmt::format("Recompressed {} from {} to {} bytes",
+                                      file.path(),
+                                      old_size,
+                                      new_size));
                   auto size_change_kibibyte =
                     kibibyte_size_diff(file, new_dir_entry);
                   if (size_change_kibibyte != 0) {
@@ -922,8 +930,11 @@ LocalStorage::recompress(const std::optional<int8_t> level,
                         size_change_kibibyte);
                     });
                   }
-                } catch (core::Error&) {
-                  // Ignore for now.
+                } catch (core::Error& e) {
+                  // LOG_RAW+fmt::format instead of LOG due to GCC 12.3 bug
+                  // #109241
+                  LOG_RAW(fmt::format(
+                    "Error when recompressing {}: {}", file.path(), e.what()));
                   incompressible_size += file.size_on_disk();
                 }
               });