-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop remaining uses of external "tar"
Also, fetchGit now runs in O(1) memory since we pipe the output of 'git archive' directly into unpackTarball() (rather than first reading it all into memory).
- Loading branch information
Showing
7 changed files
with
43 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
#include "rust-ffi.hh" | ||
#include "compression.hh" | ||
|
||
extern "C" { | ||
rust::CBox2<rust::Result<std::tuple<>>> unpack_tarfile(rust::Source source, rust::StringSlice dest_dir); | ||
} | ||
|
||
namespace nix { | ||
|
||
void unpackTarfile(Source & source, Path destDir) | ||
void unpackTarfile(Source & source, const Path & destDir) | ||
{ | ||
unpack_tarfile(source, destDir).use()->unwrap(); | ||
} | ||
|
||
void unpackTarfile(const Path & tarFile, const Path & destDir, | ||
std::optional<std::string> baseName) | ||
{ | ||
if (!baseName) baseName = baseNameOf(tarFile); | ||
|
||
auto source = sinkToSource([&](Sink & sink) { | ||
// FIXME: look at first few bytes to determine compression type. | ||
auto decompressor = | ||
// FIXME: add .gz support | ||
hasSuffix(*baseName, ".bz2") ? makeDecompressionSink("bzip2", sink) : | ||
hasSuffix(*baseName, ".xz") ? makeDecompressionSink("xz", sink) : | ||
makeDecompressionSink("none", sink); | ||
readFile(tarFile, *decompressor); | ||
decompressor->finish(); | ||
}); | ||
|
||
unpackTarfile(*source, destDir); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters