]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Ensure existing directory before copying from secondary storage
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 20 Jan 2022 19:57:09 +0000 (20:57 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 20 Jan 2022 19:59:02 +0000 (20:59 +0100)
Fixes #998.

src/storage/Storage.cpp

index 374965befb73d8c86b474046e5a9ed4bb8f0fff5..e29f856f3daf1766cf0598b4d69a91d8c334ef23 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021 Joel Rosdahl and other contributors
+// Copyright (C) 2021-2022 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -276,6 +276,7 @@ Storage::get(const Digest& key, const core::CacheEntryType type)
   if (share_hits) {
     primary.put(key, type, [&](const auto& path) {
       try {
+        Util::ensure_dir_exists(Util::dir_name(path));
         Util::copy_file(tmp_file.path, path);
       } catch (const core::Error& e) {
         LOG("Failed to copy {} to {}: {}", tmp_file.path, path, e.what());