mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 12:06:01 +01:00
feat(libstore/http-binary-cache-store): narinfo/ls/log compression
This commit is contained in:
parent
b6f4788a8f
commit
689fa81dc9
2 changed files with 36 additions and 1 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include "nix/store/nar-info-disk-cache.hh"
|
||||
#include "nix/util/callback.hh"
|
||||
#include "nix/store/store-registration.hh"
|
||||
#include "nix/util/compression.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
|
@ -142,8 +143,27 @@ protected:
|
|||
const std::string & mimeType) override
|
||||
{
|
||||
auto req = makeRequest(path);
|
||||
req.data = StreamToSourceAdapter(istream).drain();
|
||||
|
||||
auto data = StreamToSourceAdapter(istream).drain();
|
||||
|
||||
// Determine compression method based on file type
|
||||
std::string compressionMethod;
|
||||
if (hasSuffix(path, ".narinfo"))
|
||||
compressionMethod = config->narinfoCompression;
|
||||
else if (hasSuffix(path, ".ls"))
|
||||
compressionMethod = config->lsCompression;
|
||||
else if (hasPrefix(path, "log/"))
|
||||
compressionMethod = config->logCompression;
|
||||
|
||||
// Apply compression if configured
|
||||
if (!compressionMethod.empty()) {
|
||||
data = compress(compressionMethod, data);
|
||||
req.headers.emplace_back("Content-Encoding", compressionMethod);
|
||||
}
|
||||
|
||||
req.data = std::move(data);
|
||||
req.mimeType = mimeType;
|
||||
|
||||
try {
|
||||
getFileTransfer()->upload(req);
|
||||
} catch (FileTransferError & e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue