From 2e954a436b7c990e12eb98de9a6a9ba995dd9429 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Thu, 27 Jun 2024 17:12:06 +0200 Subject: Use (un)expected for CAS access --- src/buildtool/storage/compactifier.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/buildtool/storage/compactifier.cpp') diff --git a/src/buildtool/storage/compactifier.cpp b/src/buildtool/storage/compactifier.cpp index c8d65e8e..e9997efb 100644 --- a/src/buildtool/storage/compactifier.cpp +++ b/src/buildtool/storage/compactifier.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include "src/buildtool/common/bazel_types.hpp" @@ -283,21 +282,18 @@ template // Split the entry: auto split_result = IsTreeObject(kType) ? task.cas.SplitTree(*digest) : task.cas.SplitBlob(*digest); - auto* parts = std::get_if>(&split_result); - if (parts == nullptr) { - auto* error = std::get_if(&split_result); - auto const error_message = error ? std::move(*error).Message() : ""; + if (not split_result) { task.Log(LogLevel::Error, "Failed to split {}\nDigest: {}\nMessage: {}", path.string(), digest->hash(), - error_message); + std::move(split_result).error().Message()); return false; } // If the file cannot actually be split (the threshold is too low), the // file must not be deleted. - if (parts->size() < 2) { + if (split_result->size() < 2) { task.Log(LogLevel::Debug, "{} cannot be compactified. The compactification " "threshold is too low.", -- cgit v1.2.3