From 574c62a94f61265be5ae3d086834fa8b9d29eefc Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Mon, 24 Feb 2025 12:38:18 +0100 Subject: strip leading path separator when creating workspace shares (#285) --- CHANGELOG.md | 1 + src/zen/cmds/workspaces_cmd.cpp | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38b152f8a..d73c5954b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Bugfix: Verify that chunking is allowed before chunking loose files duriung oplog export - Bugfix: Fix oplog target url for oplog export to remote zenserver - Bugfix: Handle workspace share paths enclosed in quotes and ending with backslash UE-231677 +- Bugfix: Strip leading path separator when creating workspace shares ## 5.5.17 - Improvement: Batch fetch record attachments when appropriate diff --git a/src/zen/cmds/workspaces_cmd.cpp b/src/zen/cmds/workspaces_cmd.cpp index 05d3c573f..166d4218d 100644 --- a/src/zen/cmds/workspaces_cmd.cpp +++ b/src/zen/cmds/workspaces_cmd.cpp @@ -25,7 +25,7 @@ namespace { if (!Path.empty()) { std::u8string PathString = Path.u8string(); - if (PathString.ends_with(std::filesystem::path::preferred_separator)) + if (PathString.ends_with(std::filesystem::path::preferred_separator) || PathString.ends_with('/')) { PathString.pop_back(); Path = std::filesystem::path(PathString); @@ -42,6 +42,19 @@ namespace { } } + static void RemoveLeadingPathSeparator(std::filesystem::path& Path) + { + if (!Path.empty()) + { + std::u8string PathString = Path.u8string(); + if (PathString.starts_with(std::filesystem::path::preferred_separator) || PathString.starts_with('/')) + { + PathString.erase(PathString.begin()); + Path = std::filesystem::path(PathString); + } + } + } + void ShowShare(const Workspaces::WorkspaceShareConfiguration& Share, const Oid& WorkspaceId, std::string_view Prefix) { ZEN_CONSOLE("{}Id: {}", Prefix, Share.Id); @@ -451,6 +464,7 @@ WorkspaceShareCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** } RemoveTrailingPathSeparator(m_SharePath); + RemoveLeadingPathSeparator(m_SharePath); if (m_ShareId.empty()) { -- cgit v1.2.3