diff options
Diffstat (limited to 'src/zenserver/projectstore/projectstore.h')
| -rw-r--r-- | src/zenserver/projectstore/projectstore.h | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/zenserver/projectstore/projectstore.h b/src/zenserver/projectstore/projectstore.h index be3ee7075..7b0c96205 100644 --- a/src/zenserver/projectstore/projectstore.h +++ b/src/zenserver/projectstore/projectstore.h @@ -74,7 +74,7 @@ public: const std::filesystem::path& MarkerPath); ~Oplog(); - [[nodiscard]] static bool ExistsAt(std::filesystem::path BasePath); + [[nodiscard]] static bool ExistsAt(const std::filesystem::path& BasePath); void Read(); void Write(); @@ -113,6 +113,7 @@ public: void Flush(); void Scrub(ScrubContext& Ctx) const; void GatherReferences(GcContext& GcCtx); + static uint64_t TotalSize(const std::filesystem::path& BasePath); uint64_t TotalSize() const; std::size_t OplogCount() const @@ -121,7 +122,6 @@ public: return m_LatestOpMap.size(); } - bool IsExpired() const; std::filesystem::path PrepareForDelete(bool MoveFolder); private: @@ -208,14 +208,17 @@ public: void IterateOplogs(std::function<void(const Oplog&)>&& Fn) const; void IterateOplogs(std::function<void(Oplog&)>&& Fn); std::vector<std::string> ScanForOplogs() const; - bool IsExpired() const; + bool IsExpired(const GcClock::TimePoint ExpireTime) const; + bool IsExpired(const GcClock::TimePoint ExpireTime, const ProjectStore::Oplog& Oplog) const; + void TouchProject() const; + void TouchOplog(std::string_view Oplog) const; Project(ProjectStore* PrjStore, CidStore& Store, std::filesystem::path BasePath); virtual ~Project(); void Read(); void Write(); - [[nodiscard]] static bool Exists(std::filesystem::path BasePath); + [[nodiscard]] static bool Exists(const std::filesystem::path& BasePath); void Flush(); void Scrub(ScrubContext& Ctx); spdlog::logger& Log(); @@ -224,25 +227,29 @@ public: bool PrepareForDelete(std::filesystem::path& OutDeletePath); private: - ProjectStore* m_ProjectStore; - CidStore& m_CidStore; - mutable RwLock m_ProjectLock; - std::map<std::string, std::unique_ptr<Oplog>> m_Oplogs; - std::vector<std::unique_ptr<Oplog>> m_DeletedOplogs; - std::filesystem::path m_OplogStoragePath; + ProjectStore* m_ProjectStore; + CidStore& m_CidStore; + mutable RwLock m_ProjectLock; + std::map<std::string, std::unique_ptr<Oplog>> m_Oplogs; + std::vector<std::unique_ptr<Oplog>> m_DeletedOplogs; + std::filesystem::path m_OplogStoragePath; + mutable tsl::robin_map<std::string, GcClock::Tick> m_LastAccessTimes; std::filesystem::path BasePathForOplog(std::string_view OplogId); + bool IsExpired(const std::string& EntryName, const std::filesystem::path& MarkerPath, const GcClock::TimePoint ExpireTime) const; + void WriteAccessTimes(); + void ReadAccessTimes(); }; // Oplog* OpenProjectOplog(std::string_view ProjectId, std::string_view OplogId); Ref<Project> OpenProject(std::string_view ProjectId); - Ref<Project> NewProject(std::filesystem::path BasePath, - std::string_view ProjectId, - std::string_view RootDir, - std::string_view EngineRootDir, - std::string_view ProjectRootDir, - std::string_view ProjectFilePath); + Ref<Project> NewProject(const std::filesystem::path& BasePath, + std::string_view ProjectId, + std::string_view RootDir, + std::string_view EngineRootDir, + std::string_view ProjectRootDir, + std::string_view ProjectFilePath); bool DeleteProject(std::string_view ProjectId); bool Exists(std::string_view ProjectId); void Flush(); |