From 7ac10782ca0fcf896137f79cdaa3a3f4e74bdbeb Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 19 Apr 2023 15:32:26 +0200 Subject: just-mr archive: subdir matters! When deciding if two archive-based repositories create the same root it is not enough to compare the contents of the archive; it also matters which subdirectory we will take as root. This is especially important, if we take the same archive on the one hand for the code and also the example subdir for testing. Additionally, we cannot ignore the archive type; there are tar archives that are also zip archives, but with different content. (Tar only cares about the initial segment till it finds the two empty blocks; zip has the index at the end and ignores any initial segment that might have been prepended to a valid zip archive.) --- src/other_tools/ops_maps/content_cas_map.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/other_tools/ops_maps/content_cas_map.hpp b/src/other_tools/ops_maps/content_cas_map.hpp index a490b34a..b2f0fb58 100644 --- a/src/other_tools/ops_maps/content_cas_map.hpp +++ b/src/other_tools/ops_maps/content_cas_map.hpp @@ -40,12 +40,13 @@ struct ArchiveContent { // Used in callers of ContentCASMap which need extra fields struct ArchiveRepoInfo { - ArchiveContent archive; /* key (see ArchiveContent) */ + ArchiveContent archive; std::string repo_type; std::string subdir; [[nodiscard]] auto operator==(const ArchiveRepoInfo& other) const -> bool { - return archive.content == other.archive.content; + return archive == other.archive && subdir == other.subdir && + repo_type == other.repo_type; } }; @@ -70,9 +71,13 @@ template <> struct hash { [[nodiscard]] auto operator()(const ArchiveRepoInfo& ct) const noexcept -> std::size_t { - return std::hash{}(ct.archive); + size_t seed{}; + hash_combine(&seed, ct.archive); + hash_combine(&seed, ct.subdir); + hash_combine(&seed, ct.repo_type); + return seed; } }; } // namespace std -#endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_CONTENT_CAS_MAP_HPP \ No newline at end of file +#endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_CONTENT_CAS_MAP_HPP -- cgit v1.2.3