aboutsummaryrefslogtreecommitdiff
path: root/zenserver/cache/structuredcachestore.cpp
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-11-02 15:05:45 +0100
committerMartin Ridgers <[email protected]>2021-11-02 15:29:02 +0100
commit7f877f09f7780bb5675e80556dce00b2d7b573ee (patch)
treeb5da05cd110f34cef4c63b1f67047c957a0fe5ad /zenserver/cache/structuredcachestore.cpp
parentUnused variables fix (diff)
downloadzen-7f877f09f7780bb5675e80556dce00b2d7b573ee.tar.xz
zen-7f877f09f7780bb5675e80556dce00b2d7b573ee.zip
CacheBucket::BuildPath() uses a PathBuilder instead of a WideStrBuilder
Diffstat (limited to 'zenserver/cache/structuredcachestore.cpp')
-rw-r--r--zenserver/cache/structuredcachestore.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp
index 5566f4587..1042bbaee 100644
--- a/zenserver/cache/structuredcachestore.cpp
+++ b/zenserver/cache/structuredcachestore.cpp
@@ -472,17 +472,17 @@ ZenCacheDiskLayer::CacheBucket::OpenOrCreate(std::filesystem::path BucketDir, bo
}
void
-ZenCacheDiskLayer::CacheBucket::BuildPath(WideStringBuilderBase& Path, const IoHash& HashKey)
+ZenCacheDiskLayer::CacheBucket::BuildPath(PathBuilderBase& Path, const IoHash& HashKey)
{
char HexString[sizeof(HashKey.Hash) * 2];
ToHexBytes(HashKey.Hash, sizeof HashKey.Hash, HexString);
- Path.Append(m_BucketDir.c_str());
+ Path.Append(m_BucketDir);
Path.Append(L"/blob/");
Path.AppendAsciiRange(HexString, HexString + 3);
- Path.Append(L"/");
+ Path.AppendSeparator();
Path.AppendAsciiRange(HexString + 3, HexString + 5);
- Path.Append(L"/");
+ Path.AppendSeparator();
Path.AppendAsciiRange(HexString + 5, HexString + sizeof(HexString));
}
@@ -503,12 +503,12 @@ ZenCacheDiskLayer::CacheBucket::GetInlineCacheValue(const DiskLocation& Loc, Zen
bool
ZenCacheDiskLayer::CacheBucket::GetStandaloneCacheValue(const DiskLocation& Loc, const IoHash& HashKey, ZenCacheValue& OutValue)
{
- WideStringBuilder<128> DataFilePath;
+ PathBuilder<128> DataFilePath;
BuildPath(DataFilePath, HashKey);
RwLock::SharedLockScope ValueLock(LockForHash(HashKey));
- if (IoBuffer Data = IoBufferBuilder::MakeFromFile(DataFilePath.c_str()))
+ if (IoBuffer Data = IoBufferBuilder::MakeFromFile(DataFilePath.ToPath()))
{
OutValue.Value = Data;
OutValue.Value.SetContentType(Loc.GetContentType());
@@ -709,7 +709,7 @@ ZenCacheDiskLayer::CacheBucket::PutStandaloneCacheValue(const IoHash& HashKey, c
{
RwLock::ExclusiveLockScope ValueLock(LockForHash(HashKey));
- WideStringBuilder<128> DataFilePath;
+ PathBuilder<128> DataFilePath;
BuildPath(DataFilePath, HashKey);
TemporaryFile DataFile;
@@ -731,7 +731,7 @@ ZenCacheDiskLayer::CacheBucket::PutStandaloneCacheValue(const IoHash& HashKey, c
// Move file into place (atomically)
- std::filesystem::path FsPath{DataFilePath.c_str()};
+ std::filesystem::path FsPath{DataFilePath.ToPath()};
DataFile.MoveTemporaryIntoPlace(FsPath, Ec);
@@ -741,7 +741,7 @@ ZenCacheDiskLayer::CacheBucket::PutStandaloneCacheValue(const IoHash& HashKey, c
do
{
- std::filesystem::path ParentPath = std::filesystem::path(DataFilePath.c_str()).parent_path();
+ std::filesystem::path ParentPath = FsPath.parent_path();
CreateDirectories(ParentPath);
DataFile.MoveTemporaryIntoPlace(FsPath, Ec);
@@ -766,7 +766,7 @@ ZenCacheDiskLayer::CacheBucket::PutStandaloneCacheValue(const IoHash& HashKey, c
if (Ec)
{
- throw std::system_error(Ec, "Failed to finalize file '{}'"_format(WideToUtf8(DataFilePath)));
+ throw std::system_error(Ec, "Failed to finalize file '{}'"_format(DataFilePath.ToUtf8()));
}
}