Add HasMatchingConfigs utility to logfile_sorting.h
Change-Id: Iaa36877302c9b62e205c509804412ec0d965e2a7
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/events/logging/logfile_sorting.cc b/aos/events/logging/logfile_sorting.cc
index 41dc20e..b8530fb 100644
--- a/aos/events/logging/logfile_sorting.cc
+++ b/aos/events/logging/logfile_sorting.cc
@@ -2183,7 +2183,7 @@
// Validates that collection of log files or log parts shares the same configs.
template <typename TCollection>
-bool CheckMatchingConfigs(const TCollection &items) {
+bool HasMatchingConfigsTemplate(const TCollection &items) {
const Configuration *config = nullptr;
for (const auto &item : items) {
VLOG(1) << item;
@@ -2204,14 +2204,19 @@
return true;
}
+// Validates that collection of log files or log parts shares the same configs.
+bool HasMatchingConfigs(const std::vector<LogFile> &items) {
+ return HasMatchingConfigsTemplate(items);
+}
+
// Provides unified access to config field stored in LogFile. It is used in
-// CheckMatchingConfigs.
+// HasMatchingConfigs.
inline const Configuration *GetConfig(const LogFile &log_file) {
return log_file.config.get();
}
// Provides unified access to config field stored in LogPartsAccess. It is used
-// in CheckMatchingConfigs.
+// in HasMatchingConfigs.
inline const Configuration *GetConfig(const LogPartsAccess &log_parts_access) {
return log_parts_access.config().get();
}
@@ -2234,7 +2239,7 @@
<< boot_index_;
return;
}
- CHECK(CheckMatchingConfigs(log_parts_));
+ CHECK(HasMatchingConfigsTemplate(log_parts_));
config_ = log_parts_.front().config();
for (LogPartsAccess &part : log_parts_) {
@@ -2257,7 +2262,7 @@
std::optional<const LogSource *> log_source, std::vector<LogFile> log_files)
: log_source_(log_source), log_files_(std::move(log_files)) {
CHECK_GT(log_files_.size(), 0u);
- CHECK(CheckMatchingConfigs(log_files_));
+ CHECK(HasMatchingConfigsTemplate(log_files_));
config_ = log_files_.front().config;
boots_ = log_files_.front().boots;
diff --git a/aos/events/logging/logfile_sorting.h b/aos/events/logging/logfile_sorting.h
index 2275673..3cdfba1 100644
--- a/aos/events/logging/logfile_sorting.h
+++ b/aos/events/logging/logfile_sorting.h
@@ -150,6 +150,9 @@
// Sort parts of a single log.
std::vector<LogFile> SortParts(const LogSource &log_source);
+// Validates that collection of log files or log parts shares the same configs.
+bool HasMatchingConfigs(const std::vector<LogFile> &items);
+
// Recursively searches the file/folder for .bfbs and .bfbs.xz files and adds
// them to the vector.
void FindLogs(std::vector<internal::FileOperations::File> *files,