]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Logic error with read_only storage gating (#1747)
authorThisIsFineTM <184989147+ThisIsFineTM@users.noreply.github.com>
Mon, 8 Jun 2026 18:15:41 +0000 (18:15 +0000)
committerGitHub <noreply@github.com>
Mon, 8 Jun 2026 18:15:41 +0000 (20:15 +0200)
RemoteStorageEntry::read_only is an std::optional<bool>.
Storage::get_backend was treating read_only as a regular bool (likely a
residue left over from a refactor?). Operator bool on std::optional is
just a has_value check, so the backend storage gating was behaving as
read_only even if read_only was explicitly set to false.

src/ccache/storage/storage.cpp

index 61942e47f384c5402f40b9dc4eb3795bbda8035c..e5ecf6cc2cf93f5d33d2399402939976c2c9ae9e 100644 (file)
@@ -582,7 +582,7 @@ Storage::get_backend(RemoteStorageEntry& entry,
                      const std::string_view operation_description,
                      const bool for_writing)
 {
-  if (for_writing && entry.config.read_only) {
+  if (for_writing && entry.config.read_only.value_or(false)) {
     LOG("Not {} {} storage since it is read-only",
         operation_description,
         entry.config.shards.front().url.scheme());