fix(ui): reparse-check repo-scan root folder and move scan off UI thread

RepoScanner.Scan() only guarded reparse points on subdirectories found
during recursion, so a configured import root that is itself a junction
walked straight through onto other drives. Apply the same
FileAttributes.ReparsePoint check to the root before scanning.

RepoImportModalViewModel.ScanAndAdd ran the full 5-level recursive scan
synchronously on the UI thread; pointing the folder picker at a broad
directory froze the app. Offload RepoScanner.Scan to Task.Run per folder
and apply results back on the UI thread.

Add a RepoScannerTests case that creates a real junction (mklink /J) at
the scan root and asserts Scan returns empty.
This commit is contained in:
mika kuns
2026-08-06 14:27:39 +02:00
parent bac8387069
commit b97f55bfb6
3 changed files with 37 additions and 4 deletions
+9
View File
@@ -16,6 +16,15 @@ public static class RepoScanner
if (string.IsNullOrWhiteSpace(parentFolder) || !Directory.Exists(parentFolder))
return Array.Empty<RepoCandidate>();
try
{
var info = new DirectoryInfo(parentFolder);
if (info.Attributes.HasFlag(FileAttributes.ReparsePoint))
return Array.Empty<RepoCandidate>();
}
catch (Exception e) when (e is IOException or UnauthorizedAccessException)
{ return Array.Empty<RepoCandidate>(); }
var result = new List<RepoCandidate>();
ScanDirectory(parentFolder, depth: 0, result);
return result;