diff options
Diffstat (limited to 'zenserver/cache/structuredcachestore.cpp')
| -rw-r--r-- | zenserver/cache/structuredcachestore.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp index 140ff1853..a07fccf98 100644 --- a/zenserver/cache/structuredcachestore.cpp +++ b/zenserver/cache/structuredcachestore.cpp @@ -581,13 +581,20 @@ ZenCacheDiskLayer::Get(std::string_view InBucket, const zen::IoHash& HashKey, Ze zen::RwLock::ExclusiveLockScope _(m_Lock); - auto It = m_Buckets.try_emplace(std::string(InBucket), m_CasStore); - Bucket = &It.first->second; + if (auto it = m_Buckets.find(std::string(InBucket)); it != m_Buckets.end()) + { + Bucket = &it->second; + } + else + { + auto It = m_Buckets.try_emplace(std::string(InBucket), m_CasStore); + Bucket = &It.first->second; - std::filesystem::path BucketPath = m_RootDir; - BucketPath /= std::string(InBucket); + std::filesystem::path BucketPath = m_RootDir; + BucketPath /= std::string(InBucket); - Bucket->OpenOrCreate(BucketPath.c_str()); + Bucket->OpenOrCreate(BucketPath.c_str()); + } } ZEN_ASSERT(Bucket != nullptr); @@ -617,13 +624,20 @@ ZenCacheDiskLayer::Put(std::string_view InBucket, const zen::IoHash& HashKey, co zen::RwLock::ExclusiveLockScope _(m_Lock); - auto It = m_Buckets.try_emplace(std::string(InBucket), m_CasStore); - Bucket = &It.first->second; + if (auto it = m_Buckets.find(std::string(InBucket)); it != m_Buckets.end()) + { + Bucket = &it->second; + } + else + { + auto It = m_Buckets.try_emplace(std::string(InBucket), m_CasStore); + Bucket = &It.first->second; - std::filesystem::path bucketPath = m_RootDir; - bucketPath /= std::string(InBucket); + std::filesystem::path bucketPath = m_RootDir; + bucketPath /= std::string(InBucket); - Bucket->OpenOrCreate(bucketPath.c_str()); + Bucket->OpenOrCreate(bucketPath.c_str()); + } } ZEN_ASSERT(Bucket != nullptr); |