aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-05-16 13:10:10 +0200
committerDan Engelbrecht <[email protected]>2022-05-16 13:10:10 +0200
commit2f69a30c936bc475bf85daded3706dc67f2e8a0f (patch)
tree5f1161e6ea39218424904427b998fd92dbd5a7e7
parentuse "default" as the default namespace (diff)
downloadzen-2f69a30c936bc475bf85daded3706dc67f2e8a0f.tar.xz
zen-2f69a30c936bc475bf85daded3706dc67f2e8a0f.zip
use ns_ prefix on disk only
-rw-r--r--zenserver/cache/structuredcache.cpp5
-rw-r--r--zenserver/cache/structuredcachestore.cpp10
-rw-r--r--zenserver/cache/structuredcachestore.h4
3 files changed, 8 insertions, 11 deletions
diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp
index 9f0ff7408..6d3211c0b 100644
--- a/zenserver/cache/structuredcache.cpp
+++ b/zenserver/cache/structuredcache.cpp
@@ -119,11 +119,6 @@ namespace {
{
Key = Key.substr(HttpZCacheAPIV2Prefix.length());
// Namespace reference
- if (!Key.starts_with(ZenCacheStore::NamespacePrefix))
- {
- return false;
- }
- Key = Key.substr(ZenCacheStore::NamespacePrefix.length());
std::string_view::size_type NamespaceSplitOffset = Key.find_first_of('/');
std::string Namespace = ToLower(Key.substr(0, NamespaceSplitOffset));
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp
index 5d1d39c50..16130a98b 100644
--- a/zenserver/cache/structuredcachestore.cpp
+++ b/zenserver/cache/structuredcachestore.cpp
@@ -2140,9 +2140,9 @@ ZenCacheStore::ZenCacheStore(CasGc& Gc, std::filesystem::path BasePath) : GcStor
for (const std::filesystem::path& DirPath : DirContent.Directories)
{
std::string DirName = PathToUtf8(DirPath.stem());
- if (DirName.starts_with(NamespacePrefix))
+ if (DirName.starts_with(NamespaceDiskPrefix))
{
- Namespaces.push_back(DirName.substr(3));
+ Namespaces.push_back(DirName.substr(NamespaceDiskPrefix.length()));
continue;
}
LegacyBuckets.push_back(DirName);
@@ -2153,7 +2153,8 @@ ZenCacheStore::ZenCacheStore(CasGc& Gc, std::filesystem::path BasePath) : GcStor
if (std::find(Namespaces.begin(), Namespaces.end(), DefaultNamespace) == Namespaces.end())
{
ZEN_INFO("Moving #{} legacy buckets to anonymous namespace", LegacyBuckets.size());
- std::filesystem::path DefaultNamespaceFolder = BasePath / fmt::format("{}{}", NamespacePrefix, DefaultNamespace);
+
+ std::filesystem::path DefaultNamespaceFolder = BasePath / fmt::format("{}{}", NamespaceDiskPrefix, DefaultNamespace);
CreateDirectories(DefaultNamespaceFolder);
// Move any non-namespace folders into the default namespace folder
@@ -2168,13 +2169,14 @@ 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));
}
for (const std::string& NamespaceName : Namespaces)
{
m_Namespaces[NamespaceName] =
- std::make_unique<ZenCacheNamespace>(Gc, BasePath / fmt::format("{}{}", NamespacePrefix, NamespaceName));
+ std::make_unique<ZenCacheNamespace>(Gc, BasePath / fmt::format("{}{}", NamespaceDiskPrefix, NamespaceName));
}
}
diff --git a/zenserver/cache/structuredcachestore.h b/zenserver/cache/structuredcachestore.h
index 787cf2187..232e8b9a8 100644
--- a/zenserver/cache/structuredcachestore.h
+++ b/zenserver/cache/structuredcachestore.h
@@ -356,8 +356,8 @@ private:
class ZenCacheStore final : public GcStorage, public GcContributor
{
public:
- static constexpr std::string_view DefaultNamespace = "default";
- static constexpr std::string_view NamespacePrefix = "";
+ static constexpr std::string_view DefaultNamespace = "default";
+ static constexpr std::string_view NamespaceDiskPrefix = "ns_";
ZenCacheStore(CasGc& Gc, std::filesystem::path BasePath);
~ZenCacheStore();