aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZousar Shaker <[email protected]>2026-03-18 11:03:52 -0600
committerGitHub Enterprise <[email protected]>2026-03-18 11:03:52 -0600
commit99f1167e2e4937bf581d28b70b45815955636fc4 (patch)
treedf163fcfb67d95470bef1a169e7e7d6882be900f /src
parentadd kind positional argument to xmake sln (#857) (diff)
parentAddressing review feedback (diff)
downloadzen-99f1167e2e4937bf581d28b70b45815955636fc4.tar.xz
zen-99f1167e2e4937bf581d28b70b45815955636fc4.zip
Merge pull request #855 from ue-foundation/zs/long-filename-improvement
Zs/long filename improvement
Diffstat (limited to 'src')
-rw-r--r--src/zenremotestore/projectstore/remoteprojectstore.cpp1
-rw-r--r--src/zenserver-test/projectstore-tests.cpp92
-rw-r--r--src/zenserver/storage/projectstore/httpprojectstore.cpp9
-rw-r--r--src/zenstore/projectstore.cpp7
4 files changed, 104 insertions, 5 deletions
diff --git a/src/zenremotestore/projectstore/remoteprojectstore.cpp b/src/zenremotestore/projectstore/remoteprojectstore.cpp
index 8ba2397ff..1a9dc10ef 100644
--- a/src/zenremotestore/projectstore/remoteprojectstore.cpp
+++ b/src/zenremotestore/projectstore/remoteprojectstore.cpp
@@ -488,6 +488,7 @@ namespace remotestore_impl {
{
std::string_view ServerPath = View["serverpath"sv].AsString();
std::filesystem::path FilePath = (Project.RootDir / ServerPath).make_preferred();
+ MakeSafeAbsolutePathInPlace(FilePath);
if (!IsFile(FilePath))
{
remotestore_impl::ReportMessage(
diff --git a/src/zenserver-test/projectstore-tests.cpp b/src/zenserver-test/projectstore-tests.cpp
index 52ae937f5..5cc75c590 100644
--- a/src/zenserver-test/projectstore-tests.cpp
+++ b/src/zenserver-test/projectstore-tests.cpp
@@ -103,6 +103,35 @@ TEST_CASE("project.basic")
}
}
+ // Create a file at a path exceeding Windows MAX_PATH (260 chars) for long filename testing
+ std::filesystem::path LongPathDir = RootPath / "longpathtest";
+ for (int I = 0; I < 5; ++I)
+ {
+ LongPathDir /= std::string(50, char('a' + I));
+ }
+ std::filesystem::path LongFilePath = LongPathDir / "testfile.bin";
+ std::filesystem::path LongRelPath = LongFilePath.lexically_relative(RootPath);
+
+ const uint8_t LongPathFileData[] = {0xDE, 0xAD, 0xBE, 0xEF};
+ CreateDirectories(MakeSafeAbsolutePath(LongPathDir));
+ WriteFile(MakeSafeAbsolutePath(LongFilePath), IoBufferBuilder::MakeCloneFromMemory(LongPathFileData, sizeof(LongPathFileData)));
+ CHECK(LongRelPath.string().length() > 260);
+
+ std::string LongClientPath = "/{engine}/client";
+ for (int I = 0; I < 5; ++I)
+ {
+ LongClientPath += '/';
+ LongClientPath.append(50, char('a' + I));
+ }
+ LongClientPath += "/longfile.bin";
+ CHECK(LongClientPath.length() > 260);
+
+ const std::string_view LongPathChunkId{
+ "00000000"
+ "00000000"
+ "00020000"};
+ auto LongPathFileOid = zen::Oid::FromHexString(LongPathChunkId);
+
SUBCASE("build store persistence")
{
uint8_t AttachData[] = {1, 2, 3};
@@ -128,6 +157,11 @@ TEST_CASE("project.basic")
<< "/{engine}/client/side/path";
OpWriter << "serverpath" << BinPath.c_str();
OpWriter.EndObject();
+ OpWriter.BeginObject();
+ OpWriter << "id" << LongPathFileOid;
+ OpWriter << "clientpath" << LongClientPath;
+ OpWriter << "serverpath" << LongRelPath.c_str();
+ OpWriter.EndObject();
OpWriter.EndArray();
zen::CbObject Op = OpWriter.Save();
@@ -168,6 +202,17 @@ TEST_CASE("project.basic")
CHECK(Response.ResponsePayload.GetSize() == 10);
}
+ // Read long-path file data
+ {
+ zen::StringBuilder<128> ChunkGetUri;
+ ChunkGetUri << "/" << LongPathChunkId;
+ auto Response = Http.Get(ChunkGetUri);
+
+ REQUIRE(Response);
+ CHECK(Response.StatusCode == HttpResponseCode::OK);
+ CHECK(Response.ResponsePayload.GetSize() == sizeof(LongPathFileData));
+ }
+
ZEN_INFO("+++++++");
}
@@ -190,6 +235,11 @@ TEST_CASE("project.basic")
<< "/{engine}/client/side/path";
OpWriter << "serverpath" << BinPath.c_str();
OpWriter.EndObject();
+ OpWriter.BeginObject();
+ OpWriter << "id" << LongPathFileOid;
+ OpWriter << "clientpath" << LongClientPath;
+ OpWriter << "serverpath" << LongRelPath.c_str();
+ OpWriter.EndObject();
OpWriter.EndArray();
zen::CbObject Op = OpWriter.Save();
@@ -223,6 +273,21 @@ TEST_CASE("project.basic")
CHECK(ReferenceData.GetView().EqualBytes(Data.GetView()));
}
+ // Read long-path file data, it is raw and uncompressed
+ {
+ zen::StringBuilder<128> ChunkGetUri;
+ ChunkGetUri << "/" << LongPathChunkId;
+ auto Response = Http.Get(ChunkGetUri);
+
+ REQUIRE(Response);
+ REQUIRE(Response.StatusCode == HttpResponseCode::OK);
+
+ IoBuffer Data = Response.ResponsePayload;
+ MemoryView ExpectedView{LongPathFileData, sizeof(LongPathFileData)};
+ CHECK(Data.GetSize() == sizeof(LongPathFileData));
+ CHECK(Data.GetView().EqualBytes(ExpectedView));
+ }
+
{
IoBuffer Payload = MakeCbObjectPayload([&](CbObjectWriter& Writer) { Writer.AddString("method"sv, "snapshot"sv); });
auto Response = Http.Post("/rpc"sv, Payload);
@@ -251,6 +316,27 @@ TEST_CASE("project.basic")
CHECK(ReferenceData.GetView().EqualBytes(DataDecompressed.GetView()));
}
+ // Read compressed long-path file data after snapshot
+ {
+ zen::StringBuilder<128> ChunkGetUri;
+ ChunkGetUri << "/" << LongPathChunkId;
+ auto Response = Http.Get(ChunkGetUri, {{"Accept-Type", "application/x-ue-comp"}});
+
+ REQUIRE(Response);
+ REQUIRE(Response.StatusCode == HttpResponseCode::OK);
+
+ IoBuffer Data = Response.ResponsePayload;
+ IoHash RawHash;
+ uint64_t RawSize;
+ CompressedBuffer Compressed = CompressedBuffer::FromCompressed(SharedBuffer(Data), RawHash, RawSize);
+ REQUIRE(Compressed);
+ IoBuffer DataDecompressed = Compressed.Decompress().AsIoBuffer();
+ MemoryView ExpectedView{LongPathFileData, sizeof(LongPathFileData)};
+ CHECK(RawSize == sizeof(LongPathFileData));
+ CHECK(DataDecompressed.GetSize() == sizeof(LongPathFileData));
+ CHECK(DataDecompressed.GetView().EqualBytes(ExpectedView));
+ }
+
ZEN_INFO("+++++++");
}
@@ -268,6 +354,12 @@ TEST_CASE("project.basic")
CHECK(Response.StatusCode == HttpResponseCode::NotFound);
}
}
+
+ // Cleanup long-path test directory
+ {
+ std::error_code Ec;
+ DeleteDirectories(MakeSafeAbsolutePath(RootPath / "longpathtest"), Ec);
+ }
}
}
diff --git a/src/zenserver/storage/projectstore/httpprojectstore.cpp b/src/zenserver/storage/projectstore/httpprojectstore.cpp
index 38a121b37..425caee97 100644
--- a/src/zenserver/storage/projectstore/httpprojectstore.cpp
+++ b/src/zenserver/storage/projectstore/httpprojectstore.cpp
@@ -3161,8 +3161,10 @@ HttpProjectService::HandleRpcRequest(HttpRouterRequest& Req)
continue;
}
- std::error_code Ec;
- const std::filesystem::path FilePath = std::filesystem::canonical(Project->RootDir / ServerPath, Ec);
+ std::error_code Ec;
+ // Long paths require MakeSafeAbsolutePath otherwise canonical will yield an error code
+ const std::filesystem::path SafeAbsFilePath = MakeSafeAbsolutePath(Project->RootDir / ServerPath);
+ const std::filesystem::path FilePath = std::filesystem::canonical(SafeAbsFilePath, Ec);
if (Ec)
{
@@ -3183,7 +3185,8 @@ HttpProjectService::HandleRpcRequest(HttpRouterRequest& Req)
}
BasicFile DataFile;
- DataFile.Open(FilePath, BasicFile::Mode::kRead, Ec);
+ // Must use SafeAbsFilePath because canonical will have removed leading chars for handling long paths
+ DataFile.Open(SafeAbsFilePath, BasicFile::Mode::kRead, Ec);
if (Ec)
{
diff --git a/src/zenstore/projectstore.cpp b/src/zenstore/projectstore.cpp
index 03086b473..56d0f7d2b 100644
--- a/src/zenstore/projectstore.cpp
+++ b/src/zenstore/projectstore.cpp
@@ -2403,8 +2403,9 @@ ProjectStore::Oplog::IterateChunks(const std::filesystem::path& P
{
return;
}
- size_t FileChunkIndex = FileChunkIndexes[ChunkIndex];
- const std::filesystem::path& FilePath = FileChunkPaths[ChunkIndex];
+ size_t FileChunkIndex = FileChunkIndexes[ChunkIndex];
+ std::filesystem::path FilePath = FileChunkPaths[ChunkIndex];
+ MakeSafeAbsolutePathInPlace(FilePath);
try
{
IoBuffer Payload = IoBufferBuilder::MakeFromFile(FilePath);
@@ -2522,6 +2523,8 @@ ProjectStore::Oplog::FindChunk(const std::filesystem::path& ProjectRootDir, cons
OplogLock.ReleaseNow();
+ MakeSafeAbsolutePathInPlace(FilePath);
+
IoBuffer Result = IoBufferBuilder::MakeFromFile(FilePath);
if (!Result)
{