Skip to content

Commit 9f55775

Browse files
committed
Fix NuGet restore walk package store detection
Fix two issues preventing package stores from being skipped during restore walk: 1. Strip trailing slashes from package folder paths parsed from project.assets.json to match paths from dir.join(name) for proper equality checks 2. Check if directories are package stores when popping from pending queue, not just when queueing, to handle stores that are queued before their project.assets.json is parsed This prevents large in-tree package stores from exhausting the directory budget before deeper project.assets.json files are processed.
1 parent 01ff0ff commit 9f55775

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎crates/socket-patch-core/src/crawlers/nuget_crawler.rs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,15 @@ fn parse_project_assets(content: &str) -> Option<ProjectAssets> {
616616
let package_folders = json
617617
.get("packageFolders")
618618
.and_then(|folders| folders.as_object())
619-
.map(|folders| folders.keys().map(PathBuf::from).collect())
619+
.map(|folders| {
620+
folders
621+
.keys()
622+
.map(|key| {
623+
let path = key.strip_suffix('/').unwrap_or(key);
624+
PathBuf::from(path)
625+
})
626+
.collect()
627+
})
620628
.unwrap_or_default();
621629
let libraries = json
622630
.get("libraries")
@@ -684,6 +692,9 @@ fn restore_walk(cwd: &Path, skip: &[PathBuf]) -> RestoreWalk {
684692
let mut pending = vec![root];
685693
let mut listed = 0usize;
686694
while let Some(dir) = pending.pop() {
695+
if skip.contains(&dir) || walk.package_folders.contains(&dir) {
696+
continue;
697+
}
687698
listed += 1;
688699
if listed > SCOPE_DIR_BUDGET {
689700
walk.libraries = None;

0 commit comments

Comments
 (0)