Compress NAR listings using the "text-compression" method

So if "text-compression=br", the .ls file in S3 will get a
Content-Encoding of "br". Brotli appears to compress better than xz
for this kind of file and is natively supported by browsers.
This commit is contained in:
Eelco Dolstra 2017-03-14 15:55:02 +01:00
parent 45c70382ac
commit 042975ea8e
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 3 additions and 3 deletions

View file

@ -224,7 +224,7 @@ void BinaryCacheStore::addToStore(const ValidPathInfo & info, const ref<std::str
}
}
upsertFile(storePathToHash(info.path) + ".ls.xz", *compress("xz", jsonOut.str()), "application/x-nix-nar-listing");
upsertFile(storePathToHash(info.path) + ".ls", jsonOut.str(), "application/json");
}
else {

View file

@ -267,9 +267,9 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore
void upsertFile(const std::string & path, const std::string & data,
const std::string & mimeType) override
{
if (path.find(".narinfo") != std::string::npos)
if (textCompression != "" && (hasSuffix(path, ".narinfo") || hasSuffix(path, ".ls")))
uploadFile(path, *compress(textCompression, data), mimeType, textCompression);
else if (path.find("/log") != std::string::npos)
else if (logCompression != "" && hasPrefix(path, "log/"))
uploadFile(path, *compress(logCompression, data), mimeType, logCompression);
else
uploadFile(path, data, mimeType, "");