1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-12 13:36:02 +01:00

refactor(libstore/find-cycles): rename scanForCycleEdges2 → walkAndScanPath

The "2" suffix was unclear and didn't communicate the function's purpose.
The new name better describes what it does: walks the filesystem tree and
scans each file using the provided sink.
This commit is contained in:
Bernardo Meurer Costa 2025-10-11 20:23:37 +00:00
parent c70df0a2da
commit d381d24fe3
No known key found for this signature in database
2 changed files with 8 additions and 8 deletions

View file

@ -69,7 +69,7 @@ void scanForCycleEdges(const Path & path, const StorePathSet & refs, StoreCycleE
CycleEdgeScanSink sink(std::move(hashes), storePrefix); CycleEdgeScanSink sink(std::move(hashes), storePrefix);
// Walk the filesystem and scan files using the sink // Walk the filesystem and scan files using the sink
scanForCycleEdges2(path, sink); walkAndScanPath(path, sink);
// Extract the found edges // Extract the found edges
edges = sink.getEdges(); edges = sink.getEdges();
@ -79,12 +79,12 @@ void scanForCycleEdges(const Path & path, const StorePathSet & refs, StoreCycleE
* Recursively walk filesystem and stream files into the sink. * Recursively walk filesystem and stream files into the sink.
* This reuses RefScanSink's hash-finding logic instead of reimplementing it. * This reuses RefScanSink's hash-finding logic instead of reimplementing it.
*/ */
void scanForCycleEdges2(const std::string & path, CycleEdgeScanSink & sink) void walkAndScanPath(const std::string & path, CycleEdgeScanSink & sink)
{ {
auto fsPath = std::filesystem::path(path); auto fsPath = std::filesystem::path(path);
auto status = std::filesystem::symlink_status(fsPath); auto status = std::filesystem::symlink_status(fsPath);
debug("scanForCycleEdges2: scanning path = %s", path); debug("walkAndScanPath: scanning path = %s", path);
if (std::filesystem::is_regular_file(status)) { if (std::filesystem::is_regular_file(status)) {
// Handle regular files - stream contents into sink // Handle regular files - stream contents into sink
@ -122,14 +122,14 @@ void scanForCycleEdges2(const std::string & path, CycleEdgeScanSink & sink)
} }
for (auto & [name, actualName] : unhacked) { for (auto & [name, actualName] : unhacked) {
debug("scanForCycleEdges2: recursing into %s/%s", path, actualName); debug("walkAndScanPath: recursing into %s/%s", path, actualName);
scanForCycleEdges2((fsPath / actualName).string(), sink); walkAndScanPath((fsPath / actualName).string(), sink);
} }
} else if (std::filesystem::is_symlink(status)) { } else if (std::filesystem::is_symlink(status)) {
// Handle symlinks - stream link target into sink // Handle symlinks - stream link target into sink
auto linkTarget = std::filesystem::read_symlink(fsPath).string(); auto linkTarget = std::filesystem::read_symlink(fsPath).string();
debug("scanForCycleEdges2: scanning symlink %s -> %s", path, linkTarget); debug("walkAndScanPath: scanning symlink %s -> %s", path, linkTarget);
sink.setCurrentPath(path); sink.setCurrentPath(path);
sink(std::string_view(linkTarget)); sink(std::string_view(linkTarget));

View file

@ -77,7 +77,7 @@ public:
void scanForCycleEdges(const Path & path, const StorePathSet & refs, StoreCycleEdgeVec & edges); void scanForCycleEdges(const Path & path, const StorePathSet & refs, StoreCycleEdgeVec & edges);
/** /**
* Recursively scan files and directories for hash references. * Recursively walk filesystem tree and scan each file for hash references.
* *
* This function walks the file system tree, streaming file contents into * This function walks the file system tree, streaming file contents into
* the provided sink which performs the actual hash detection. This reuses * the provided sink which performs the actual hash detection. This reuses
@ -86,7 +86,7 @@ void scanForCycleEdges(const Path & path, const StorePathSet & refs, StoreCycleE
* @param path Current path being scanned * @param path Current path being scanned
* @param sink The CycleEdgeScanSink that will detect and record hash references * @param sink The CycleEdgeScanSink that will detect and record hash references
*/ */
void scanForCycleEdges2(const std::string & path, CycleEdgeScanSink & sink); void walkAndScanPath(const std::string & path, CycleEdgeScanSink & sink);
/** /**
* Transform individual edges into connected multi-edges (paths). * Transform individual edges into connected multi-edges (paths).