diff options
| author | Dan Engelbrecht <[email protected]> | 2024-09-10 17:07:06 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-09-10 17:07:06 +0200 |
| commit | 535ffb70546eb10635e56bf266f38599f3034279 (patch) | |
| tree | 471916bcd5a523454366eb54db330925b5fa88ba /src | |
| parent | Replicate releases on new release creation (#150) (diff) | |
| download | zen-535ffb70546eb10635e56bf266f38599f3034279.tar.xz zen-535ffb70546eb10635e56bf266f38599f3034279.zip | |
validate oplog before opening - if invalid, warn and wipe oplog (#153)
Diffstat (limited to 'src')
| -rw-r--r-- | src/zenserver/projectstore/projectstore.cpp | 14 |
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; |