aboutsummaryrefslogtreecommitdiff
path: root/src/zen/cmds
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2025-01-29 15:08:03 +0100
committerStefan Boberg <[email protected]>2025-01-29 15:08:03 +0100
commite64c8727ecb073ca03e2c7d4b3972c375c1b6315 (patch)
tree04a1a7c178c43666de7f7f9b472ed156f6373da5 /src/zen/cmds
parentMerge branch 'main' of https://github.ol.epicgames.net/ue-foundation/zen (diff)
parenthandle special backslash followed by quote for paths (#279) (diff)
downloadarchived-zen-sb/cleanup-main.tar.xz
archived-zen-sb/cleanup-main.zip
Merge branch 'main' of https://github.ol.epicgames.net/ue-foundation/zensb/cleanup-main
Diffstat (limited to 'src/zen/cmds')
-rw-r--r--src/zen/cmds/admin_cmd.cpp7
-rw-r--r--src/zen/cmds/cache_cmd.cpp2
-rw-r--r--src/zen/cmds/copy_cmd.cpp4
-rw-r--r--src/zen/cmds/print_cmd.cpp2
-rw-r--r--src/zen/cmds/projectstore_cmd.cpp9
-rw-r--r--src/zen/cmds/rpcreplay_cmd.cpp2
-rw-r--r--src/zen/cmds/serve_cmd.cpp4
-rw-r--r--src/zen/cmds/workspaces_cmd.cpp20
8 files changed, 32 insertions, 18 deletions
diff --git a/src/zen/cmds/admin_cmd.cpp b/src/zen/cmds/admin_cmd.cpp
index e07e28f54..995ed4136 100644
--- a/src/zen/cmds/admin_cmd.cpp
+++ b/src/zen/cmds/admin_cmd.cpp
@@ -1,12 +1,13 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "admin_cmd.h"
+
+#include <zencore/basicfile.h>
#include <zencore/filesystem.h>
#include <zencore/logging.h>
#include <zenhttp/formatters.h>
#include <zenhttp/httpclient.h>
#include <zenhttp/httpcommon.h>
-#include <zenutil/basicfile.h>
ZEN_THIRD_PARTY_INCLUDES_START
#include <cpr/cpr.h>
@@ -736,14 +737,14 @@ CopyStateCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
// Copy cache state
DirectoryContent CacheDirectoryContent;
- GetDirectoryContent(CachePath, DirectoryContent::IncludeDirsFlag, CacheDirectoryContent);
+ GetDirectoryContent(CachePath, DirectoryContentFlags::IncludeDirs, CacheDirectoryContent);
for (const std::filesystem::path& NamespacePath : CacheDirectoryContent.Directories)
{
std::filesystem::path NamespaceName = NamespacePath.filename();
std::filesystem::path TargetNamespacePath = TargetCachePath / NamespaceName;
DirectoryContent CacheNamespaceContent;
- GetDirectoryContent(NamespacePath, DirectoryContent::IncludeDirsFlag, CacheNamespaceContent);
+ GetDirectoryContent(NamespacePath, DirectoryContentFlags::IncludeDirs, CacheNamespaceContent);
for (const std::filesystem::path& BucketPath : CacheNamespaceContent.Directories)
{
diff --git a/src/zen/cmds/cache_cmd.cpp b/src/zen/cmds/cache_cmd.cpp
index 00099cebc..6ec6a80db 100644
--- a/src/zen/cmds/cache_cmd.cpp
+++ b/src/zen/cmds/cache_cmd.cpp
@@ -12,8 +12,8 @@
#include <zencore/workthreadpool.h>
#include <zenhttp/httpclient.h>
#include <zenhttp/httpcommon.h>
+#include <zenhttp/packageformat.h>
#include <zenutil/cache/cacherequests.h>
-#include <zenutil/packageformat.h>
#include <memory>
#include <random>
diff --git a/src/zen/cmds/copy_cmd.cpp b/src/zen/cmds/copy_cmd.cpp
index f39bfa71c..d42d3c107 100644
--- a/src/zen/cmds/copy_cmd.cpp
+++ b/src/zen/cmds/copy_cmd.cpp
@@ -120,7 +120,7 @@ CopyCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
{
}
- virtual void VisitFile(const std::filesystem::path& Parent, const path_view& File, uint64_t FileSize) override
+ virtual void VisitFile(const std::filesystem::path& Parent, const path_view& File, uint64_t FileSize, uint32_t) override
{
ZEN_UNUSED(FileSize);
std::error_code Ec;
@@ -157,7 +157,7 @@ CopyCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
}
}
- virtual bool VisitDirectory(const std::filesystem::path&, const path_view&) override { return true; }
+ virtual bool VisitDirectory(const std::filesystem::path&, const path_view&, uint32_t) override { return true; }
std::filesystem::path BasePath;
std::filesystem::path TargetPath;
diff --git a/src/zen/cmds/print_cmd.cpp b/src/zen/cmds/print_cmd.cpp
index fa42a3563..469dddf55 100644
--- a/src/zen/cmds/print_cmd.cpp
+++ b/src/zen/cmds/print_cmd.cpp
@@ -8,7 +8,7 @@
#include <zencore/fmtutils.h>
#include <zencore/logging.h>
#include <zencore/string.h>
-#include <zenutil/packageformat.h>
+#include <zenhttp/packageformat.h>
using namespace std::literals;
diff --git a/src/zen/cmds/projectstore_cmd.cpp b/src/zen/cmds/projectstore_cmd.cpp
index 5e18a3624..6bc499f03 100644
--- a/src/zen/cmds/projectstore_cmd.cpp
+++ b/src/zen/cmds/projectstore_cmd.cpp
@@ -2,6 +2,7 @@
#include "projectstore_cmd.h"
+#include <zencore/basicfile.h>
#include <zencore/compactbinarybuilder.h>
#include <zencore/compress.h>
#include <zencore/filesystem.h>
@@ -14,7 +15,6 @@
#include <zenhttp/formatters.h>
#include <zenhttp/httpclient.h>
#include <zenhttp/httpcommon.h>
-#include <zenutil/basicfile.h>
ZEN_THIRD_PARTY_INCLUDES_START
#include <cpr/cpr.h>
@@ -1047,15 +1047,16 @@ ExportOplogCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** arg
TargetUrlBase = fmt::format("http://{}", TargetUrlBase);
}
+ HttpClient TargetHttp(TargetUrlBase);
std::string Url = fmt::format("/prj/{}/oplog/{}", m_ZenProjectName, m_ZenOplogName);
bool CreateOplog = false;
- if (HttpClient::Response Result = Http.Get(Url, HttpClient::Accept(ZenContentType::kJSON)))
+ if (HttpClient::Response Result = TargetHttp.Get(Url, HttpClient::Accept(ZenContentType::kJSON)))
{
if (m_ZenClean)
{
ZEN_WARN("Deleting zen remote oplog '{}/{}'", m_ZenProjectName, m_ZenOplogName)
- Result = Http.Delete(Url, HttpClient::Accept(ZenContentType::kJSON));
+ Result = TargetHttp.Delete(Url, HttpClient::Accept(ZenContentType::kJSON));
if (!Result)
{
Result.ThrowError("failed deleting existing zen remote oplog"sv);
@@ -1077,7 +1078,7 @@ ExportOplogCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** arg
if (CreateOplog)
{
ZEN_WARN("Creating zen remote oplog '{}/{}'", m_ZenProjectName, m_ZenOplogName);
- if (HttpClient::Response Result = Http.Post(Url); !Result)
+ if (HttpClient::Response Result = TargetHttp.Post(Url); !Result)
{
Result.ThrowError("failed creating zen remote oplog"sv);
return 1;
diff --git a/src/zen/cmds/rpcreplay_cmd.cpp b/src/zen/cmds/rpcreplay_cmd.cpp
index d66adfb81..5b88a1f73 100644
--- a/src/zen/cmds/rpcreplay_cmd.cpp
+++ b/src/zen/cmds/rpcreplay_cmd.cpp
@@ -13,8 +13,8 @@
#include <zencore/timer.h>
#include <zencore/workthreadpool.h>
#include <zenhttp/httpcommon.h>
+#include <zenhttp/packageformat.h>
#include <zenutil/cache/rpcrecording.h>
-#include <zenutil/packageformat.h>
ZEN_THIRD_PARTY_INCLUDES_START
#include <cpr/cpr.h>
diff --git a/src/zen/cmds/serve_cmd.cpp b/src/zen/cmds/serve_cmd.cpp
index ea9102b28..8e36e74ce 100644
--- a/src/zen/cmds/serve_cmd.cpp
+++ b/src/zen/cmds/serve_cmd.cpp
@@ -120,7 +120,7 @@ ServeCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
struct FsVisitor : public FileSystemTraversal::TreeVisitor
{
- virtual void VisitFile(const std::filesystem::path& Parent, const path_view& File, uint64_t FileSize) override
+ virtual void VisitFile(const std::filesystem::path& Parent, const path_view& File, uint64_t FileSize, uint32_t) override
{
std::filesystem::path ServerPath = std::filesystem::relative(Parent / File, RootPath);
std::string ServerPathString = reinterpret_cast<const char*>(ServerPath.generic_u8string().c_str());
@@ -133,7 +133,7 @@ ServeCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
Files.emplace_back(FileEntry{ServerPathString, ServerPathString, FileSize});
}
- virtual bool VisitDirectory(const std::filesystem::path&, const path_view&) override { return true; }
+ virtual bool VisitDirectory(const std::filesystem::path&, const path_view&, uint32_t) override { return true; }
struct FileEntry
{
diff --git a/src/zen/cmds/workspaces_cmd.cpp b/src/zen/cmds/workspaces_cmd.cpp
index 2c8fe43f6..05d3c573f 100644
--- a/src/zen/cmds/workspaces_cmd.cpp
+++ b/src/zen/cmds/workspaces_cmd.cpp
@@ -22,11 +22,23 @@ namespace zen {
namespace {
static void RemoveTrailingPathSeparator(std::filesystem::path& Path)
{
- std::u8string PathString = Path.u8string();
- if (PathString.ends_with(std::filesystem::path::preferred_separator))
+ if (!Path.empty())
{
- PathString.pop_back();
- Path = std::filesystem::path(PathString);
+ std::u8string PathString = Path.u8string();
+ if (PathString.ends_with(std::filesystem::path::preferred_separator))
+ {
+ PathString.pop_back();
+ Path = std::filesystem::path(PathString);
+ }
+ // Special case if user gives a path with quotes and includes a backslash at the end:
+ // ="path\" cxxopts strips the leading quote only but not the trailing.
+ // As we expect paths here and we don't want trailing slashes we strip away the quote
+ // manually if the string does not start with a quote UE-231677
+ else if (PathString[0] != '\"' && PathString[PathString.length() - 1] == '\"')
+ {
+ PathString.pop_back();
+ Path = std::filesystem::path(PathString);
+ }
}
}