]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Disable hard link and file clone with enabled secondary storage
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 7 Nov 2021 12:37:47 +0000 (13:37 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 8 Nov 2021 20:32:21 +0000 (21:32 +0100)
src/Config.hpp
src/ccache.cpp
src/storage/Storage.cpp
src/storage/Storage.hpp

index acb09e990322b01ec419a67437e29a662af4e631..9383106bd24d8e5685f0946082f248f6fe9b49d9 100644 (file)
@@ -92,6 +92,8 @@ public:
   void set_debug(bool value);
   void set_depend_mode(bool value);
   void set_direct_mode(bool value);
+  void set_file_clone(bool value);
+  void set_hard_link(bool value);
   void set_ignore_options(const std::string& value);
   void set_inode_cache(bool value);
   void set_max_files(uint64_t value);
@@ -489,6 +491,18 @@ Config::set_direct_mode(bool value)
   m_direct_mode = value;
 }
 
+inline void
+Config::set_file_clone(const bool value)
+{
+  m_file_clone = value;
+}
+
+inline void
+Config::set_hard_link(const bool value)
+{
+  m_hard_link = value;
+}
+
 inline void
 Config::set_ignore_options(const std::string& value)
 {
index c32200f40982f012a4611f0527dbf11861f44c55..406ae738e06132dcb036a8d17edc04a171a29b7e 100644 (file)
@@ -2024,6 +2024,17 @@ do_cache_compilation(Context& ctx, const char* const* argv)
     ctx.config.set_depend_mode(false);
   }
 
+  if (ctx.storage.has_secondary_storage()) {
+    if (ctx.config.file_clone()) {
+      LOG_RAW("Disabling file clone mode since secondary storage is enabled");
+      ctx.config.set_file_clone(false);
+    }
+    if (ctx.config.hard_link()) {
+      LOG_RAW("Disabling hard link mode since secondary storage is enabled");
+      ctx.config.set_hard_link(false);
+    }
+  }
+
   LOG("Source file: {}", ctx.args_info.input_file);
   if (ctx.args_info.generating_dependencies) {
     LOG("Dependency file: {}", ctx.args_info.output_dep);
index 497bfcb9c343e0dfcaaaa935f34298525684888f..f5ba67e3fcfe8ed29bbdcab2695ebf477e257c4e 100644 (file)
@@ -329,6 +329,12 @@ Storage::remove(const Digest& key, const core::CacheEntryType type)
   remove_from_secondary_storage(key);
 }
 
+bool
+Storage::has_secondary_storage() const
+{
+  return !m_secondary_storages.empty();
+}
+
 std::string
 Storage::get_secondary_storage_config_for_logging() const
 {
index 3e596745ad9be36956f655aa7c4caa86f680c71d..2b245d1a1e659302f8927805e30f8d1d30653b54 100644 (file)
@@ -61,6 +61,7 @@ public:
 
   void remove(const Digest& key, core::CacheEntryType type);
 
+  bool has_secondary_storage() const;
   std::string get_secondary_storage_config_for_logging() const;
 
 private: