aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-03-25 22:57:24 +0100
committerGitHub Enterprise <[email protected]>2024-03-25 22:57:24 +0100
commit9fef50ff26e5c9c56e0794947305429f27da17e8 (patch)
treed610ef436b5ded08d62492618a1b80d3ac802f72 /src
parentadd a limit to the number of times we attempt to finalize (#22) (diff)
downloadzen-9fef50ff26e5c9c56e0794947305429f27da17e8.tar.xz
zen-9fef50ff26e5c9c56e0794947305429f27da17e8.zip
consistent paths encoding (#24)
* Don't encode filesystem path to UTF8 unless stored in compactbinary string * Be consistent where we encode/decode paths to UTF8
Diffstat (limited to 'src')
-rw-r--r--src/zenserver/diag/logging.cpp4
-rw-r--r--src/zenserver/projectstore/httpprojectstore.cpp30
-rw-r--r--src/zenserver/projectstore/projectstore.cpp42
-rw-r--r--src/zenserver/projectstore/projectstore.h24
-rw-r--r--src/zenutil/logging.cpp2
5 files changed, 52 insertions, 50 deletions
diff --git a/src/zenserver/diag/logging.cpp b/src/zenserver/diag/logging.cpp
index dc1675819..595be70cb 100644
--- a/src/zenserver/diag/logging.cpp
+++ b/src/zenserver/diag/logging.cpp
@@ -37,7 +37,7 @@ InitializeServerLogging(const ZenServerOptions& InOptions)
std::filesystem::path HttpLogPath = InOptions.DataDir / "logs" / "http.log";
zen::CreateDirectories(HttpLogPath.parent_path());
- auto HttpSink = std::make_shared<zen::logging::RotatingFileSink>(zen::PathToUtf8(HttpLogPath),
+ auto HttpSink = std::make_shared<zen::logging::RotatingFileSink>(HttpLogPath,
/* max size */ 128 * 1024 * 1024,
/* max files */ 16,
/* rotate on open */ true);
@@ -49,7 +49,7 @@ InitializeServerLogging(const ZenServerOptions& InOptions)
std::filesystem::path CacheLogPath = InOptions.DataDir / "logs" / "z$.log";
zen::CreateDirectories(CacheLogPath.parent_path());
- auto CacheSink = std::make_shared<zen::logging::RotatingFileSink>(zen::PathToUtf8(CacheLogPath),
+ auto CacheSink = std::make_shared<zen::logging::RotatingFileSink>(CacheLogPath,
/* max size */ 128 * 1024 * 1024,
/* max files */ 16,
/* rotate on open */ false);
diff --git a/src/zenserver/projectstore/httpprojectstore.cpp b/src/zenserver/projectstore/httpprojectstore.cpp
index bc71e2fa0..260f60cfe 100644
--- a/src/zenserver/projectstore/httpprojectstore.cpp
+++ b/src/zenserver/projectstore/httpprojectstore.cpp
@@ -1417,13 +1417,14 @@ HttpProjectService::HandleProjectRequest(HttpRouterRequest& Req)
return HttpReq.WriteResponse(HttpResponseCode::InsufficientStorage);
}
- IoBuffer Payload = HttpReq.ReadPayload();
- CbObject Params = LoadCompactBinaryObject(Payload);
- std::string_view Root = Params["root"sv].AsString(); // Workspace root (i.e `D:/UE5/`)
- std::string_view EngineRoot = Params["engine"sv].AsString(); // Engine root (i.e `D:/UE5/Engine`)
- std::string_view ProjectRoot = Params["project"sv].AsString(); // Project root directory (i.e `D:/UE5/Samples/Games/Lyra`)
- std::string_view ProjectFilePath =
- Params["projectfile"sv].AsString(); // Project file path (i.e `D:/UE5/Samples/Games/Lyra/Lyra.uproject`)
+ IoBuffer Payload = HttpReq.ReadPayload();
+ CbObject Params = LoadCompactBinaryObject(Payload);
+ std::filesystem::path Root = Params["root"sv].AsU8String(); // Workspace root (i.e `D:/UE5/`)
+ std::filesystem::path EngineRoot = Params["engine"sv].AsU8String(); // Engine root (i.e `D:/UE5/Engine`)
+ std::filesystem::path ProjectRoot =
+ Params["project"sv].AsU8String(); // Project root directory (i.e `D:/UE5/Samples/Games/Lyra`)
+ std::filesystem::path ProjectFilePath =
+ Params["projectfile"sv].AsU8String(); // Project file path (i.e `D:/UE5/Samples/Games/Lyra/Lyra.uproject`)
const std::filesystem::path BasePath = m_ProjectStore->BasePath() / ProjectId;
m_ProjectStore->NewProject(BasePath, ProjectId, Root, EngineRoot, ProjectRoot, ProjectFilePath);
@@ -1448,13 +1449,14 @@ HttpProjectService::HandleProjectRequest(HttpRouterRequest& Req)
return HttpReq.WriteResponse(HttpResponseCode::InsufficientStorage);
}
- IoBuffer Payload = HttpReq.ReadPayload();
- CbObject Params = LoadCompactBinaryObject(Payload);
- std::string_view Root = Params["root"sv].AsString(); // Workspace root (i.e `D:/UE5/`)
- std::string_view EngineRoot = Params["engine"sv].AsString(); // Engine root (i.e `D:/UE5/Engine`)
- std::string_view ProjectRoot = Params["project"sv].AsString(); // Project root directory (i.e `D:/UE5/Samples/Games/Lyra`)
- std::string_view ProjectFilePath =
- Params["projectfile"sv].AsString(); // Project file path (i.e `D:/UE5/Samples/Games/Lyra/Lyra.uproject`)
+ IoBuffer Payload = HttpReq.ReadPayload();
+ CbObject Params = LoadCompactBinaryObject(Payload);
+ std::filesystem::path Root = Params["root"sv].AsU8String(); // Workspace root (i.e `D:/UE5/`)
+ std::filesystem::path EngineRoot = Params["engine"sv].AsU8String(); // Engine root (i.e `D:/UE5/Engine`)
+ std::filesystem::path ProjectRoot =
+ Params["project"sv].AsU8String(); // Project root directory (i.e `D:/UE5/Samples/Games/Lyra`)
+ std::filesystem::path ProjectFilePath =
+ Params["projectfile"sv].AsU8String(); // Project file path (i.e `D:/UE5/Samples/Games/Lyra/Lyra.uproject`)
if (m_ProjectStore->UpdateProject(ProjectId, Root, EngineRoot, ProjectRoot, ProjectFilePath))
{
diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp
index e4a39e55f..7af543dbc 100644
--- a/src/zenserver/projectstore/projectstore.cpp
+++ b/src/zenserver/projectstore/projectstore.cpp
@@ -788,7 +788,7 @@ ProjectStore::Oplog::Read()
CbObject Cfg = LoadCompactBinaryObject(Obj);
- m_MarkerPath = Cfg["gcpath"sv].AsString();
+ m_MarkerPath = Cfg["gcpath"sv].AsU8String();
}
else
{
@@ -1529,11 +1529,11 @@ ProjectStore::Project::Read()
{
CbObject Cfg = LoadCompactBinaryObject(Obj);
- Identifier = Cfg["id"sv].AsString();
- RootDir = Cfg["root"sv].AsString();
- ProjectRootDir = Cfg["project"sv].AsString();
- EngineRootDir = Cfg["engine"sv].AsString();
- ProjectFilePath = Cfg["projectfile"sv].AsString();
+ Identifier = std::filesystem::path(Cfg["id"sv].AsU8String()).string();
+ RootDir = std::filesystem::path(Cfg["root"sv].AsU8String()).string();
+ ProjectRootDir = std::filesystem::path(Cfg["project"sv].AsU8String()).string();
+ EngineRootDir = std::filesystem::path(Cfg["engine"sv].AsU8String()).string();
+ ProjectFilePath = std::filesystem::path(Cfg["projectfile"sv].AsU8String()).string();
}
else
{
@@ -1555,9 +1555,9 @@ ProjectStore::Project::Write()
CbObjectWriter Cfg;
Cfg << "id"sv << Identifier;
Cfg << "root"sv << PathToUtf8(RootDir);
- Cfg << "project"sv << ProjectRootDir;
- Cfg << "engine"sv << EngineRootDir;
- Cfg << "projectfile"sv << ProjectFilePath;
+ Cfg << "project"sv << PathToUtf8(ProjectRootDir);
+ Cfg << "engine"sv << PathToUtf8(EngineRootDir);
+ Cfg << "projectfile"sv << PathToUtf8(ProjectFilePath);
Cfg.Save(Mem);
@@ -2374,10 +2374,10 @@ ProjectStore::OpenProject(std::string_view ProjectId)
Ref<ProjectStore::Project>
ProjectStore::NewProject(const std::filesystem::path& BasePath,
std::string_view ProjectId,
- std::string_view RootDir,
- std::string_view EngineRootDir,
- std::string_view ProjectRootDir,
- std::string_view ProjectFilePath)
+ const std::filesystem::path& RootDir,
+ const std::filesystem::path& EngineRootDir,
+ const std::filesystem::path& ProjectRootDir,
+ const std::filesystem::path& ProjectFilePath)
{
ZEN_TRACE_CPU("Store::NewProject");
@@ -2397,11 +2397,11 @@ ProjectStore::NewProject(const std::filesystem::path& BasePath,
}
bool
-ProjectStore::UpdateProject(std::string_view ProjectId,
- std::string_view RootDir,
- std::string_view EngineRootDir,
- std::string_view ProjectRootDir,
- std::string_view ProjectFilePath)
+ProjectStore::UpdateProject(std::string_view ProjectId,
+ const std::filesystem::path& RootDir,
+ const std::filesystem::path& EngineRootDir,
+ const std::filesystem::path& ProjectRootDir,
+ const std::filesystem::path& ProjectFilePath)
{
ZEN_TRACE_CPU("Store::UpdateProject");
@@ -2491,9 +2491,9 @@ ProjectStore::GetProjectsList()
Response.BeginObject();
Response << "Id"sv << Prj.Identifier;
Response << "RootDir"sv << Prj.RootDir.string();
- Response << "ProjectRootDir"sv << Prj.ProjectRootDir;
- Response << "EngineRootDir"sv << Prj.EngineRootDir;
- Response << "ProjectFilePath"sv << Prj.ProjectFilePath;
+ Response << "ProjectRootDir"sv << PathToUtf8(Prj.ProjectRootDir);
+ Response << "EngineRootDir"sv << PathToUtf8(Prj.EngineRootDir);
+ Response << "ProjectFilePath"sv << PathToUtf8(Prj.ProjectFilePath);
Response.EndObject();
});
Response.EndArray();
diff --git a/src/zenserver/projectstore/projectstore.h b/src/zenserver/projectstore/projectstore.h
index eda336150..191dcf1f8 100644
--- a/src/zenserver/projectstore/projectstore.h
+++ b/src/zenserver/projectstore/projectstore.h
@@ -232,9 +232,9 @@ public:
{
std::string Identifier;
std::filesystem::path RootDir;
- std::string EngineRootDir;
- std::string ProjectRootDir;
- std::string ProjectFilePath;
+ std::filesystem::path EngineRootDir;
+ std::filesystem::path ProjectRootDir;
+ std::filesystem::path ProjectFilePath;
Oplog* NewOplog(std::string_view OplogId, const std::filesystem::path& MarkerPath);
Oplog* OpenOplog(std::string_view OplogId);
@@ -287,15 +287,15 @@ public:
Ref<Project> OpenProject(std::string_view ProjectId);
Ref<Project> NewProject(const std::filesystem::path& BasePath,
std::string_view ProjectId,
- std::string_view RootDir,
- std::string_view EngineRootDir,
- std::string_view ProjectRootDir,
- std::string_view ProjectFilePath);
- bool UpdateProject(std::string_view ProjectId,
- std::string_view RootDir,
- std::string_view EngineRootDir,
- std::string_view ProjectRootDir,
- std::string_view ProjectFilePath);
+ const std::filesystem::path& RootDir,
+ const std::filesystem::path& EngineRootDir,
+ const std::filesystem::path& ProjectRootDir,
+ const std::filesystem::path& ProjectFilePath);
+ bool UpdateProject(std::string_view ProjectId,
+ const std::filesystem::path& RootDir,
+ const std::filesystem::path& EngineRootDir,
+ const std::filesystem::path& ProjectRootDir,
+ const std::filesystem::path& ProjectFilePath);
bool RemoveProject(std::string_view ProjectId, std::filesystem::path& OutDeletePath);
bool DeleteProject(std::string_view ProjectId);
bool Exists(std::string_view ProjectId);
diff --git a/src/zenutil/logging.cpp b/src/zenutil/logging.cpp
index eef6a59ce..4f8c5e59e 100644
--- a/src/zenutil/logging.cpp
+++ b/src/zenutil/logging.cpp
@@ -80,7 +80,7 @@ BeginInitializeLogging(const LoggingOptions& LogOptions)
zen::CreateDirectories(LogOptions.AbsLogFile.parent_path());
}
- FileSink = std::make_shared<zen::logging::RotatingFileSink>(zen::PathToUtf8(LogOptions.AbsLogFile),
+ FileSink = std::make_shared<zen::logging::RotatingFileSink>(LogOptions.AbsLogFile,
/* max size */ 128 * 1024 * 1024,
/* max files */ 16,
/* rotate on open */ true);