const auto file_size_and_count_diff = result_writer.finalize();
if (file_size_and_count_diff) {
- ctx.storage.primary().increment_statistic(
+ ctx.storage.primary.increment_statistic(
Statistic::cache_size_kibibyte, file_size_and_count_diff->size_kibibyte);
- ctx.storage.primary().increment_statistic(Statistic::files_in_cache,
- file_size_and_count_diff->count);
+ ctx.storage.primary.increment_statistic(Statistic::files_in_cache,
+ file_size_and_count_diff->count);
} else {
LOG("Error: {}", file_size_and_count_diff.error());
throw Failure(Statistic::internal_error);
return;
}
- core::Statistics statistics(ctx.storage.primary().get_statistics_updates());
+ core::Statistics statistics(ctx.storage.primary.get_statistics_updates());
const auto result_message = statistics.get_result_message();
if (result_message) {
LOG("Result: {}", *result_message);
return;
}
- core::Statistics statistics(ctx.storage.primary().get_statistics_updates());
+ core::Statistics statistics(ctx.storage.primary.get_statistics_updates());
const auto result_id = statistics.get_result_id();
if (!result_id) {
return;
try {
Statistic statistic = do_cache_compilation(ctx, argv);
- ctx.storage.primary().increment_statistic(statistic);
+ ctx.storage.primary.increment_statistic(statistic);
} catch (const Failure& e) {
if (e.statistic() != Statistic::none) {
- ctx.storage.primary().increment_statistic(e.statistic());
+ ctx.storage.primary.increment_statistic(e.statistic());
}
if (e.exit_code()) {
case EVICT_OLDER_THAN: {
auto seconds = Util::parse_duration(arg);
ProgressBar progress_bar("Evicting...");
- ctx.storage.primary().clean_old(
+ ctx.storage.primary.clean_old(
[&](double progress) { progress_bar.update(progress); }, seconds);
if (isatty(STDOUT_FILENO)) {
PRINT_RAW(stdout, "\n");
core::StatisticsCounters counters;
time_t last_updated;
std::tie(counters, last_updated) =
- ctx.storage.primary().get_all_statistics();
+ ctx.storage.primary.get_all_statistics();
core::Statistics statistics(counters);
PRINT_RAW(stdout, statistics.format_machine_readable(last_updated));
break;
case 'c': // --cleanup
{
ProgressBar progress_bar("Cleaning...");
- ctx.storage.primary().clean_all(
+ ctx.storage.primary.clean_all(
[&](double progress) { progress_bar.update(progress); });
if (isatty(STDOUT_FILENO)) {
PRINT_RAW(stdout, "\n");
case 'C': // --clear
{
ProgressBar progress_bar("Clearing...");
- ctx.storage.primary().wipe_all(
+ ctx.storage.primary.wipe_all(
[&](double progress) { progress_bar.update(progress); });
if (isatty(STDOUT_FILENO)) {
PRINT_RAW(stdout, "\n");
core::StatisticsCounters counters;
time_t last_updated;
std::tie(counters, last_updated) =
- ctx.storage.primary().get_all_statistics();
+ ctx.storage.primary.get_all_statistics();
core::Statistics statistics(counters);
PRINT_RAW(stdout, statistics.format_config_header(ctx.config));
PRINT_RAW(stdout, statistics.format_human_readable(last_updated, false));
case 'x': // --show-compression
{
ProgressBar progress_bar("Scanning...");
- ctx.storage.primary().print_compression_statistics(
+ ctx.storage.primary.print_compression_statistics(
[&](double progress) { progress_bar.update(progress); });
break;
}
}
ProgressBar progress_bar("Recompressing...");
- ctx.storage.primary().recompress(
+ ctx.storage.primary.recompress(
wanted_level, [&](double progress) { progress_bar.update(progress); });
break;
}
case 'z': // --zero-stats
- ctx.storage.primary().zero_all_statistics();
+ ctx.storage.primary.zero_all_statistics();
PRINT_RAW(stdout, "Statistics zeroed\n");
break;
}
}
-Storage::Storage(const Config& config)
- : m_config(config),
- m_primary_storage(config)
+Storage::Storage(const Config& config) : primary(config), m_config(config)
{
}
void
Storage::initialize()
{
- m_primary_storage.initialize();
+ primary.initialize();
add_secondary_storages();
}
void
Storage::finalize()
{
- m_primary_storage.finalize();
+ primary.finalize();
}
nonstd::optional<std::string>
Storage::get(const Digest& key, const core::CacheEntryType type)
{
- const auto path = m_primary_storage.get(key, type);
+ const auto path = primary.get(key, type);
if (path) {
return path;
}
throw core::Fatal("Error writing to {}: {}", tmp_file.path, e.what());
}
- m_primary_storage.put(key, type, [&](const std::string& path) {
+ primary.put(key, type, [&](const std::string& path) {
try {
Util::copy_file(tmp_file.path, path);
} catch (const core::Error& e) {
const core::CacheEntryType type,
const storage::EntryWriter& entry_writer)
{
- const auto path = m_primary_storage.put(key, type, entry_writer);
+ const auto path = primary.put(key, type, entry_writer);
if (!path) {
return false;
}
void
Storage::remove(const Digest& key, const core::CacheEntryType type)
{
- m_primary_storage.remove(key, type);
+ primary.remove(key, type);
remove_from_secondary_storage(key);
}