From 76c5774982fa96d9551b360d541db8a7dba9ab7e Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Tue, 21 Sep 2021 12:55:42 +0200 Subject: Fixed an issue in scrubbing which would flag certain chunks as invalid Added some more context to log output --- zenstore/compactcas.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'zenstore/compactcas.cpp') diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp index fe38f0fde..f17b8d376 100644 --- a/zenstore/compactcas.cpp +++ b/zenstore/compactcas.cpp @@ -5,6 +5,7 @@ #include "CompactCas.h" #include +#include #include #include #include @@ -32,7 +33,9 @@ CasContainerStrategy::Initialize(const std::string_view ContainerBaseName, uint6 ZEN_ASSERT(IsPow2(Alignment)); ZEN_ASSERT(!m_IsInitialized); - m_PayloadAlignment = Alignment; + m_ContainerBaseName = ContainerBaseName; + m_PayloadAlignment = Alignment; + std::string BaseName(ContainerBaseName); std::filesystem::path SobsPath = m_Config.RootDirectory / (BaseName + ".ucas"); std::filesystem::path SidxPath = m_Config.RootDirectory / (BaseName + ".uidx"); @@ -210,7 +213,7 @@ CasContainerStrategy::Scrub(ScrubContext& Ctx) continue; } - const IoHash ComputedHash = IoHash::HashBuffer(BufferBase, Entry.second.Size); + const IoHash ComputedHash = IoHash::HashBuffer(reinterpret_cast(BufferBase) + Entry.second.Offset - WindowStart, Entry.second.Size); if (Entry.first != ComputedHash) { @@ -242,6 +245,13 @@ CasContainerStrategy::Scrub(ScrubContext& Ctx) } } + if (BadChunks.empty()) + { + return; + } + + ZEN_ERROR("Scrubbing found {} bad chunks in '{}'", BadChunks.size(), m_ContainerBaseName); + // Deal with bad chunks by removing them from our lookup map std::vector BadChunkHashes; -- cgit v1.2.3