Skip to content

Commit

Permalink
Compress NAR listings using the "text-compression" method
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
edolstra committed Mar 15, 2017
1 parent 45c7038 commit 042975e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/libstore/binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/libstore/s3-binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
Expand Down

0 comments on commit 042975e

Please sign in to comment.