aboutsummaryrefslogtreecommitdiff
path: root/zenserver/cache/structuredcachestore.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-05-19 15:11:35 +0200
committerDan Engelbrecht <[email protected]>2022-05-19 15:11:35 +0200
commitb373a645f787f28a4f7a831c161553df6fd4d72c (patch)
tree014dd6efe3f4a55c443fd05e9c867dcc951e5ac7 /zenserver/cache/structuredcachestore.cpp
parentKeep Namespace out of CacheKey and store it on request level (diff)
downloadzen-b373a645f787f28a4f7a831c161553df6fd4d72c.tar.xz
zen-b373a645f787f28a4f7a831c161553df6fd4d72c.zip
migrate legacy cache folders to ue4.ddc namespace
map default namespace to at runtime ue4.ddc use a non-valid name for the default namespace so we avoid any collision or accidental creation of folder for that
Diffstat (limited to 'zenserver/cache/structuredcachestore.cpp')
-rw-r--r--zenserver/cache/structuredcachestore.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp
index 6b7b73dcf..9218c2cbb 100644
--- a/zenserver/cache/structuredcachestore.cpp
+++ b/zenserver/cache/structuredcachestore.cpp
@@ -2128,6 +2128,8 @@ ZenCacheDiskLayer::TotalSize() const
//////////////////////////// ZenCacheStore
+static constexpr std::string_view UE4DDCNamespaceName = "ue4.ddc";
+
ZenCacheStore::ZenCacheStore(CasGc& Gc, std::filesystem::path BasePath) : GcStorage(Gc), GcContributor(Gc)
{
CreateDirectories(BasePath);
@@ -2150,11 +2152,13 @@ ZenCacheStore::ZenCacheStore(CasGc& Gc, std::filesystem::path BasePath) : GcStor
ZEN_INFO("Found #{} namespaces in '{}' and #{} legacy buckets", Namespaces.size(), BasePath, LegacyBuckets.size());
- if (std::find(Namespaces.begin(), Namespaces.end(), DefaultNamespace) == Namespaces.end())
+ if (std::find(Namespaces.begin(), Namespaces.end(), UE4DDCNamespaceName) == Namespaces.end())
{
- ZEN_INFO("Moving #{} legacy buckets to anonymous namespace", LegacyBuckets.size());
+ // default (unspecified) and ue4-ddc namespace points to the same namespace instance
+
+ ZEN_INFO("Moving #{} legacy buckets to '{}' namespace", LegacyBuckets.size(), UE4DDCNamespaceName);
- std::filesystem::path DefaultNamespaceFolder = BasePath / fmt::format("{}{}", NamespaceDiskPrefix, DefaultNamespace);
+ std::filesystem::path DefaultNamespaceFolder = BasePath / fmt::format("{}{}", NamespaceDiskPrefix, UE4DDCNamespaceName);
CreateDirectories(DefaultNamespaceFolder);
// Move any non-namespace folders into the default namespace folder
@@ -2169,8 +2173,7 @@ ZenCacheStore::ZenCacheStore(CasGc& Gc, std::filesystem::path BasePath) : GcStor
ZEN_ERROR("Unable to move '{}' to '{}', reason '{}'", LegacyFolder, NewPath, Ec.message());
}
}
-
- Namespaces.push_back(std::string(DefaultNamespace));
+ Namespaces.push_back(std::string(UE4DDCNamespaceName));
}
for (const std::string& NamespaceName : Namespaces)
@@ -2237,6 +2240,13 @@ ZenCacheStore::GetNamespace(std::string_view Namespace)
{
return It->second.get();
}
+ if (Namespace == DefaultNamespace)
+ {
+ if (auto It = m_Namespaces.find(std::string(UE4DDCNamespaceName)); It != m_Namespaces.end())
+ {
+ return It->second.get();
+ }
+ }
return nullptr;
}
@@ -2249,6 +2259,10 @@ ZenCacheStore::IterateNamespaces(const std::function<void(std::string_view Names
Namespaces.reserve(m_Namespaces.size());
for (const auto& Entry : m_Namespaces)
{
+ if (Entry.first == DefaultNamespace)
+ {
+ continue;
+ }
Namespaces.push_back({Entry.first, *Entry.second});
}
}