diff options
| author | Dan Engelbrecht <[email protected]> | 2022-05-01 22:34:31 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-05-01 22:34:31 +0200 |
| commit | be12749e0adde39d47875d3c4d2136dbcffbcb3d (patch) | |
| tree | 9cb340f4b66ea30472f1fea4ac130bd69786ee53 /zenstore/blockstore.cpp | |
| parent | threading issues resolved (diff) | |
| download | zen-be12749e0adde39d47875d3c4d2136dbcffbcb3d.tar.xz zen-be12749e0adde39d47875d3c4d2136dbcffbcb3d.zip | |
collectgarbage for compactcas and structured cache uses shared implementation
Diffstat (limited to 'zenstore/blockstore.cpp')
| -rw-r--r-- | zenstore/blockstore.cpp | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/zenstore/blockstore.cpp b/zenstore/blockstore.cpp index 4cf3c6486..309c99d1e 100644 --- a/zenstore/blockstore.cpp +++ b/zenstore/blockstore.cpp @@ -1,11 +1,11 @@ // Copyright Epic Games, Inc. All Rights Reserved. -#include "compactcas.h" +#include <zenstore/blockstore.h> #include <zencore/fmtutils.h> #include <zencore/logging.h> #include <zencore/scopeguard.h> -#include <zenstore/blockstore.h> +#include <zencore/timer.h> #if ZEN_WITH_TESTS # include <zencore/compactbinarybuilder.h> @@ -111,26 +111,6 @@ BlockStoreFile::StreamByteRange(uint64_t FileOffset, uint64_t Size, std::functio m_File.StreamByteRange(FileOffset, Size, std::move(ChunkFun)); } -namespace { - const char* DataExtension = ".ucas"; - - std::filesystem::path GetBlockPath(const std::filesystem::path& BlocksBasePath, const uint32_t BlockIndex) - { - ExtendablePathBuilder<256> Path; - - char BlockHexString[9]; - ToHexNumber(BlockIndex, BlockHexString); - - Path.Append(BlocksBasePath); - Path.AppendSeparator(); - Path.AppendAsciiRange(BlockHexString, BlockHexString + 4); - Path.AppendSeparator(); - Path.Append(BlockHexString); - Path.Append(DataExtension); - return Path.ToPath(); - } -} // namespace - void BlockStore::Initialize(const std::filesystem::path& BlocksBasePath, uint64_t MaxBlockSize, @@ -171,7 +151,7 @@ BlockStore::Initialize(const std::filesystem::path& BlocksBasePath, if (Entry.is_regular_file()) { const std::filesystem::path Path = Entry.path(); - if (Path.extension() != DataExtension) + if (Path.extension() != GetBlockFileExtension()) { continue; } @@ -595,6 +575,29 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot, return; } +const char* +BlockStore::GetBlockFileExtension() +{ + return ".ucas"; +} + +std::filesystem::path +BlockStore::GetBlockPath(const std::filesystem::path& BlocksBasePath, const uint32_t BlockIndex) +{ + ExtendablePathBuilder<256> Path; + + char BlockHexString[9]; + ToHexNumber(BlockIndex, BlockHexString); + + Path.Append(BlocksBasePath); + Path.AppendSeparator(); + Path.AppendAsciiRange(BlockHexString, BlockHexString + 4); + Path.AppendSeparator(); + Path.Append(BlockHexString); + Path.Append(GetBlockFileExtension()); + return Path.ToPath(); +} + #if ZEN_WITH_TESTS static bool |