mirror of
https://github.com/NixOS/nix.git
synced 2024-11-21 22:32:26 +00:00
fix: copy fileName before calling std::distance
This commit is contained in:
parent
1db7d1b840
commit
4d0777ca69
@ -22,11 +22,12 @@ void builtinUnpackChannel(
|
||||
unpackTarfile(src, out);
|
||||
|
||||
auto entries = std::filesystem::directory_iterator{out};
|
||||
auto file_count = std::distance(entries, std::filesystem::directory_iterator{});
|
||||
auto fileName = entries->path().string();
|
||||
auto fileCount = std::distance(std::filesystem::begin(entries), std::filesystem::end(entries));
|
||||
|
||||
if (file_count != 1)
|
||||
if (fileCount != 1)
|
||||
throw Error("channel tarball '%s' contains more than one file", src);
|
||||
renameFile(entries->path().string(), (out + "/" + channelName));
|
||||
renameFile(fileName, (out + "/" + channelName));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user