aboutsummaryrefslogtreecommitdiff
path: root/src/zen
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-01-23 12:49:46 +0100
committerDan Engelbrecht <[email protected]>2025-01-23 12:49:46 +0100
commit5d47e5946da5ccdba5bd2fb770b7bdfabb48fb4c (patch)
treecb64f2d93a9f5e8b0e1529ab0dc3371602688a4f /src/zen
parentchangelog (diff)
parenthandle special backslash followed by quote for paths (#279) (diff)
downloadarchived-zen-5d47e5946da5ccdba5bd2fb770b7bdfabb48fb4c.tar.xz
archived-zen-5d47e5946da5ccdba5bd2fb770b7bdfabb48fb4c.zip
Merge remote-tracking branch 'origin/main' into de/zen-service-command
Diffstat (limited to 'src/zen')
-rw-r--r--src/zen/cmds/admin_cmd.cpp4
-rw-r--r--src/zen/cmds/copy_cmd.cpp4
-rw-r--r--src/zen/cmds/serve_cmd.cpp4
-rw-r--r--src/zen/cmds/workspaces_cmd.cpp20
4 files changed, 22 insertions, 10 deletions
diff --git a/src/zen/cmds/admin_cmd.cpp b/src/zen/cmds/admin_cmd.cpp
index 31e6886b2..995ed4136 100644
--- a/src/zen/cmds/admin_cmd.cpp
+++ b/src/zen/cmds/admin_cmd.cpp
@@ -737,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/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/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);
+ }
}
}