diff options
| author | Martin Ridgers <[email protected]> | 2021-11-02 15:05:45 +0100 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2021-11-02 15:29:02 +0100 |
| commit | 7f877f09f7780bb5675e80556dce00b2d7b573ee (patch) | |
| tree | b5da05cd110f34cef4c63b1f67047c957a0fe5ad | |
| parent | Unused variables fix (diff) | |
| download | zen-7f877f09f7780bb5675e80556dce00b2d7b573ee.tar.xz zen-7f877f09f7780bb5675e80556dce00b2d7b573ee.zip | |
CacheBucket::BuildPath() uses a PathBuilder instead of a WideStrBuilder
| -rw-r--r-- | zenserver/cache/structuredcachestore.cpp | 20 | ||||
| -rw-r--r-- | zenserver/cache/structuredcachestore.h | 4 |
2 files changed, 12 insertions, 12 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())); } } diff --git a/zenserver/cache/structuredcachestore.h b/zenserver/cache/structuredcachestore.h index 5adc7492e..aabd91529 100644 --- a/zenserver/cache/structuredcachestore.h +++ b/zenserver/cache/structuredcachestore.h @@ -21,7 +21,7 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen { -class WideStringBuilderBase; +class PathBuilderBase; class CasStore; /****************************************************************************** @@ -186,7 +186,7 @@ private: tsl::robin_map<IoHash, DiskLocation, IoHash::Hasher> m_Index; uint64_t m_WriteCursor = 0; - void BuildPath(WideStringBuilderBase& Path, const IoHash& HashKey); + void BuildPath(PathBuilderBase& Path, const IoHash& HashKey); void PutStandaloneCacheValue(const IoHash& HashKey, const ZenCacheValue& Value); bool GetStandaloneCacheValue(const DiskLocation& Loc, const IoHash& HashKey, ZenCacheValue& OutValue); bool GetInlineCacheValue(const DiskLocation& Loc, ZenCacheValue& OutValue); |