mirror of
https://github.com/NixOS/nix.git
synced 2024-11-24 15:52:30 +00:00
Merge pull request #11019 from DeterminateSystems/fix-failed-to-open-archive
Tarball fetcher: Fix handling of cached tarballs
This commit is contained in:
commit
8f280d72ff
@ -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,10 +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 {
|
||||||
} 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);
|
||||||
}
|
}
|
||||||
@ -97,8 +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_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");
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,10 @@ in
|
|||||||
assert info["revision"] == "${nixpkgs.rev}"
|
assert info["revision"] == "${nixpkgs.rev}"
|
||||||
assert info["revCount"] == 1234
|
assert info["revCount"] == 1234
|
||||||
|
|
||||||
# Check that fetching with rev/revCount/narHash succeeds.
|
# Check that a 0-byte HTTP 304 "Not modified" result works.
|
||||||
|
machine.succeed("nix flake metadata --refresh --json http://localhost/tags/latest.tar.gz")
|
||||||
|
|
||||||
|
# Check that fetching with rev/revCount/narHash succeeds.
|
||||||
machine.succeed("nix flake metadata --json http://localhost/tags/latest.tar.gz?rev=" + info["revision"])
|
machine.succeed("nix flake metadata --json http://localhost/tags/latest.tar.gz?rev=" + info["revision"])
|
||||||
machine.succeed("nix flake metadata --json http://localhost/tags/latest.tar.gz?revCount=" + str(info["revCount"]))
|
machine.succeed("nix flake metadata --json http://localhost/tags/latest.tar.gz?revCount=" + str(info["revCount"]))
|
||||||
machine.succeed("nix flake metadata --json http://localhost/tags/latest.tar.gz?narHash=" + info["locked"]["narHash"])
|
machine.succeed("nix flake metadata --json http://localhost/tags/latest.tar.gz?narHash=" + info["locked"]["narHash"])
|
||||||
|
Loading…
Reference in New Issue
Block a user