mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Document
This commit is contained in:
parent
8bdd0ecd80
commit
e7e070d36b
2 changed files with 16 additions and 9 deletions
|
@ -67,6 +67,17 @@ int getArchiveFilterCodeByName(const std::string & method)
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void enableSupportedFormats(struct archive * archive)
|
||||||
|
{
|
||||||
|
archive_read_support_format_tar(archive);
|
||||||
|
archive_read_support_format_zip(archive);
|
||||||
|
|
||||||
|
/* Enable support for empty files so we don't throw an exception
|
||||||
|
for empty HTTP 304 "Not modified" responses. See
|
||||||
|
downloadTarball(). */
|
||||||
|
archive_read_support_format_empty(archive);
|
||||||
|
}
|
||||||
|
|
||||||
TarArchive::TarArchive(Source & source, bool raw, std::optional<std::string> compression_method)
|
TarArchive::TarArchive(Source & source, bool raw, std::optional<std::string> compression_method)
|
||||||
: archive{archive_read_new()}
|
: archive{archive_read_new()}
|
||||||
, source{&source}
|
, source{&source}
|
||||||
|
@ -78,11 +89,9 @@ TarArchive::TarArchive(Source & source, bool raw, std::optional<std::string> com
|
||||||
archive_read_support_filter_by_code(archive, getArchiveFilterCodeByName(*compression_method));
|
archive_read_support_filter_by_code(archive, getArchiveFilterCodeByName(*compression_method));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!raw) {
|
if (!raw)
|
||||||
archive_read_support_format_tar(archive);
|
enableSupportedFormats(archive);
|
||||||
archive_read_support_format_zip(archive);
|
else {
|
||||||
archive_read_support_format_empty(archive);
|
|
||||||
} else {
|
|
||||||
archive_read_support_format_raw(archive);
|
archive_read_support_format_raw(archive);
|
||||||
archive_read_support_format_empty(archive);
|
archive_read_support_format_empty(archive);
|
||||||
}
|
}
|
||||||
|
@ -98,9 +107,7 @@ TarArchive::TarArchive(const Path & path)
|
||||||
, buffer(defaultBufferSize)
|
, buffer(defaultBufferSize)
|
||||||
{
|
{
|
||||||
archive_read_support_filter_all(archive);
|
archive_read_support_filter_all(archive);
|
||||||
archive_read_support_format_tar(archive);
|
enableSupportedFormats(archive);
|
||||||
archive_read_support_format_zip(archive);
|
|
||||||
archive_read_support_format_empty(archive);
|
|
||||||
archive_read_set_option(archive, NULL, "mac-ext", NULL);
|
archive_read_set_option(archive, NULL, "mac-ext", NULL);
|
||||||
check(archive_read_open_filename(archive, path.c_str(), 16384), "failed to open archive: %s");
|
check(archive_read_open_filename(archive, path.c_str(), 16384), "failed to open archive: %s");
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ in
|
||||||
assert info["revision"] == "${nixpkgs.rev}"
|
assert info["revision"] == "${nixpkgs.rev}"
|
||||||
assert info["revCount"] == 1234
|
assert info["revCount"] == 1234
|
||||||
|
|
||||||
# Check that a 0-byte cached (304) result works.
|
# Check that a 0-byte HTTP 304 "Not modified" result works.
|
||||||
machine.succeed("nix flake metadata --refresh --json http://localhost/tags/latest.tar.gz")
|
machine.succeed("nix flake metadata --refresh --json http://localhost/tags/latest.tar.gz")
|
||||||
|
|
||||||
# Check that fetching with rev/revCount/narHash succeeds.
|
# Check that fetching with rev/revCount/narHash succeeds.
|
||||||
|
|
Loading…
Reference in a new issue