aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/zenserver/projectstore/projectstore.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp
index d5570e8d4..b0d2554d6 100644
--- a/src/zenserver/projectstore/projectstore.cpp
+++ b/src/zenserver/projectstore/projectstore.cpp
@@ -351,6 +351,8 @@ struct ProjectStore::OplogStorage : public RefCounted
{
return std::filesystem::exists(GetLogPath(BasePath)) && std::filesystem::exists(GetBlobsPath(BasePath));
}
+ [[nodiscard]] bool IsValid() const { return IsValid(m_OplogStoragePath); }
+ [[nodiscard]] static bool IsValid(const std::filesystem::path& BasePath) { return TCasLogFile<OplogEntry>::IsValid(BasePath); }
static bool Delete(const std::filesystem::path& BasePath) { return DeleteDirectories(BasePath); }
@@ -941,8 +943,16 @@ ProjectStore::Oplog::Oplog(std::string_view Id,
{
using namespace std::literals;
- m_Storage = new OplogStorage(this, m_BasePath);
- const bool StoreExists = m_Storage->Exists();
+ m_Storage = new OplogStorage(this, m_BasePath);
+ bool StoreExists = m_Storage->Exists();
+ if (StoreExists)
+ {
+ if (!m_Storage->IsValid())
+ {
+ ZEN_WARN("Invalid oplog found at '{}'. Wiping state for oplog.", m_BasePath);
+ StoreExists = false;
+ }
+ }
m_Storage->Open(/* IsCreate */ !StoreExists);
m_TempPath = m_BasePath / "temp"sv;
m_MetaPath = m_BasePath / "ops.meta"sv;