1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-13 05:56:03 +01:00

Dump the whole file when scaning its content

Dumping the fstream to a string just dumps a certain number of bits of
it, causing some references to be missed
This commit is contained in:
Théophane Hufschmitt 2022-04-11 10:20:36 +02:00
parent 5d47c37cbc
commit 93739ce006

View file

@ -197,15 +197,19 @@ TraceResult followPathsToStore(GlobalOpts opts, set<fs::path> roots)
*/
void scanFileContent(const GlobalOpts & opts, const fs::path & fileToScan, Roots & res)
{
std::ifstream fs;
fs.open(fileToScan);
std::string content;
fs >> content;
auto fileEnd = std::sregex_iterator();
std::ostringstream contentStream;
{
std::ifstream fs;
fs.open(fileToScan);
fs >> contentStream.rdbuf();
}
std::string content = contentStream.str();
auto regex = storePathRegex(opts.storeDir);
auto firstMatch = std::sregex_iterator(content.begin(), content.end(), regex);
for (auto & i = firstMatch; i != fileEnd; i++)
res[i->str()].insert(fileToScan);
auto firstMatch
= std::sregex_iterator { content.begin(), content.end(), regex };
auto fileEnd = std::sregex_iterator{};
for (auto i = firstMatch; i != fileEnd; ++i)
res[i->str()].emplace(fileToScan);
}
/**