diff options
Diffstat (limited to 'zenserver/testing')
| -rw-r--r-- | zenserver/testing/launch.cpp | 26 | ||||
| -rw-r--r-- | zenserver/testing/launch.h | 6 |
2 files changed, 21 insertions, 11 deletions
diff --git a/zenserver/testing/launch.cpp b/zenserver/testing/launch.cpp index 1236e6adb..0e46fff94 100644 --- a/zenserver/testing/launch.cpp +++ b/zenserver/testing/launch.cpp @@ -6,13 +6,14 @@ # include <zencore/compactbinary.h> # include <zencore/compactbinarybuilder.h> +# include <zencore/compress.h> # include <zencore/filesystem.h> # include <zencore/fmtutils.h> # include <zencore/iobuffer.h> # include <zencore/iohash.h> # include <zencore/logging.h> # include <zencore/windows.h> -# include <zenstore/cas.h> +# include <zenstore/cidstore.h> ZEN_THIRD_PARTY_INCLUDES_START # include <AccCtrl.h> @@ -322,9 +323,9 @@ SandboxedJob::SpawnJob(std::filesystem::path ExePath) //////////////////////////////////////////////////////////////////////////////// -HttpLaunchService::HttpLaunchService(CasStore& Store, const std::filesystem::path& SandboxBaseDir) +HttpLaunchService::HttpLaunchService(CidStore& Store, const std::filesystem::path& SandboxBaseDir) : m_Log(logging::Get("exec")) -, m_CasStore(Store) +, m_CidStore(Store) , m_SandboxPath(SandboxBaseDir) { m_Router.AddPattern("job", "([[:digit:]]+)"); @@ -402,7 +403,7 @@ HttpLaunchService::HttpLaunchService(CasStore& Store, const std::filesystem::pat const IoHash FileHash = Ob["hash"sv].AsHash(); - if (!m_CasStore.FindChunk(FileHash)) + if (!m_CidStore.FindChunkByCid(FileHash)) { ZEN_DEBUG("NEED: {} {} {}", FileHash, Ob["file"sv].AsString(), Ob["size"sv].AsUInt64()); @@ -465,7 +466,7 @@ HttpLaunchService::HttpLaunchService(CasStore& Store, const std::filesystem::pat const IoHash FileHash = Ob["hash"sv].AsHash(); uint64_t FileSize = Ob["size"sv].AsUInt64(); - if (IoBuffer Chunk = m_CasStore.FindChunk(FileHash); !Chunk) + if (IoBuffer Chunk = m_CidStore.FindChunkByCid(FileHash); !Chunk) { ZEN_DEBUG("MISSING: {} {} {}", FileHash, FileName, FileSize); AllOk = false; @@ -476,9 +477,18 @@ HttpLaunchService::HttpLaunchService(CasStore& Store, const std::filesystem::pat { std::filesystem::path FullPath = SandboxDir / FileName; - const IoBuffer* Chunks[] = {&Chunk}; - - zen::WriteFile(FullPath, Chunks, 1); + CompressedBuffer Compressed = CompressedBuffer::FromCompressed(SharedBuffer(Chunk)); + CompositeBuffer CompositeBuffer = Compressed.DecompressToComposite(); + std::span<const SharedBuffer> Segments = CompositeBuffer.GetSegments(); + std::vector<IoBuffer> Chunks(Segments.size()); + std::vector<IoBuffer*> ChunkPtrs(Segments.size()); + for (size_t Index = 0; Index < Segments.size(); ++Index) + { + Chunks[Index] = std::move(Segments[Index].AsIoBuffer()); + ChunkPtrs[Index] = &Chunks[Index]; + } + + zen::WriteFile(FullPath, ChunkPtrs.data(), ChunkPtrs.size()); } } diff --git a/zenserver/testing/launch.h b/zenserver/testing/launch.h index 6fd3e39ae..f44618bfb 100644 --- a/zenserver/testing/launch.h +++ b/zenserver/testing/launch.h @@ -17,7 +17,7 @@ namespace zen { -class CasStore; +class CidStore; /** * Process launcher for test executables @@ -25,7 +25,7 @@ class CasStore; class HttpLaunchService : public HttpService { public: - HttpLaunchService(CasStore& Store, const std::filesystem::path& SandboxBaseDir); + HttpLaunchService(CidStore& Store, const std::filesystem::path& SandboxBaseDir); ~HttpLaunchService(); virtual const char* BaseUri() const override; @@ -36,7 +36,7 @@ private: spdlog::logger& m_Log; HttpRequestRouter m_Router; - CasStore& m_CasStore; + CidStore& m_CidStore; std::filesystem::path m_SandboxPath; std::atomic<int> m_SandboxCount{0}; |