diff options
Diffstat (limited to 'zenserver/projectstore.cpp')
| -rw-r--r-- | zenserver/projectstore.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/zenserver/projectstore.cpp b/zenserver/projectstore.cpp index 2268b5caf..87118991e 100644 --- a/zenserver/projectstore.cpp +++ b/zenserver/projectstore.cpp @@ -111,6 +111,12 @@ struct ProjectStore::OplogStorage : public RefCounted static bool Delete(std::filesystem::path BasePath) { return DeleteDirectories(BasePath); } + uint64_t OpBlobsSize() const + { + RwLock::SharedLockScope _(m_RwLock); + return m_NextOpsOffset; + } + void Open(bool IsCreate) { using namespace std::literals; @@ -256,7 +262,7 @@ struct ProjectStore::OplogStorage : public RefCounted private: ProjectStore::Oplog* m_OwnerOplog; std::filesystem::path m_OplogStoragePath; - RwLock m_RwLock; + mutable RwLock m_RwLock; TCasLogFile<OplogEntry> m_Oplog; BasicFile m_OpBlobs; std::atomic<uint64_t> m_NextOpsOffset{0}; @@ -329,6 +335,17 @@ ProjectStore::Oplog::GatherReferences(GcContext& GcCtx) GcCtx.AddRetainedCids(Hashes); } +uint64_t +ProjectStore::Oplog::TotalSize() const +{ + RwLock::SharedLockScope _(m_OplogLock); + if (m_Storage) + { + return m_Storage->OpBlobsSize(); + } + return 0; +} + std::filesystem::path ProjectStore::Oplog::PrepareForDelete(bool MoveFolder) { @@ -912,6 +929,20 @@ ProjectStore::Project::GatherReferences(GcContext& GcCtx) IterateOplogs([&](Oplog& Ops) { Ops.GatherReferences(GcCtx); }); } +uint64_t +ProjectStore::Project::TotalSize() const +{ + uint64_t Result = 0; + { + RwLock::SharedLockScope _(m_ProjectLock); + for (const auto& It : m_Oplogs) + { + Result += It.second->TotalSize(); + } + } + return Result; +} + bool ProjectStore::Project::PrepareForDelete(std::filesystem::path& OutDeletePath) { @@ -1160,7 +1191,16 @@ ProjectStore::CollectGarbage(GcContext& GcCtx) GcStorageSize ProjectStore::StorageSize() const { - return {0, 0}; + GcStorageSize Result; + { + RwLock::SharedLockScope _(m_ProjectsLock); + for (auto& Kv : m_Projects) + { + const Ref<Project>& Project = Kv.second; + Result.DiskSize += Project->TotalSize(); + } + } + return Result; } Ref<ProjectStore::Project> |