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:
parent
5d47c37cbc
commit
93739ce006
1 changed files with 12 additions and 8 deletions
|
|
@ -196,16 +196,20 @@ TraceResult followPathsToStore(GlobalOpts opts, set<fs::path> roots)
|
||||||
* to `res`
|
* to `res`
|
||||||
*/
|
*/
|
||||||
void scanFileContent(const GlobalOpts & opts, const fs::path & fileToScan, Roots & res)
|
void scanFileContent(const GlobalOpts & opts, const fs::path & fileToScan, Roots & res)
|
||||||
|
{
|
||||||
|
std::ostringstream contentStream;
|
||||||
{
|
{
|
||||||
std::ifstream fs;
|
std::ifstream fs;
|
||||||
fs.open(fileToScan);
|
fs.open(fileToScan);
|
||||||
std::string content;
|
fs >> contentStream.rdbuf();
|
||||||
fs >> content;
|
}
|
||||||
auto fileEnd = std::sregex_iterator();
|
std::string content = contentStream.str();
|
||||||
auto regex = storePathRegex(opts.storeDir);
|
auto regex = storePathRegex(opts.storeDir);
|
||||||
auto firstMatch = std::sregex_iterator(content.begin(), content.end(), regex);
|
auto firstMatch
|
||||||
for (auto & i = firstMatch; i != fileEnd; i++)
|
= std::sregex_iterator { content.begin(), content.end(), regex };
|
||||||
res[i->str()].insert(fileToScan);
|
auto fileEnd = std::sregex_iterator{};
|
||||||
|
for (auto i = firstMatch; i != fileEnd; ++i)
|
||||||
|
res[i->str()].emplace(fileToScan);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue