enhance: reduce repository scanning time (#728)

* skip special folders, such as `node_modules`, `.svn`, `.vs` .etc.
* change max scanning depth to 5

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-21 14:18:41 +08:00
parent 069dc255d1
commit b407dd97a1
No known key found for this signature in database

View file

@ -90,6 +90,13 @@ namespace SourceGit.ViewModels
var subdirs = dir.GetDirectories("*", opts); var subdirs = dir.GetDirectories("*", opts);
foreach (var subdir in subdirs) foreach (var subdir in subdirs)
{ {
if (subdir.Name.Equals("node_modules", StringComparison.Ordinal) ||
subdir.Name.Equals(".svn", StringComparison.Ordinal) ||
subdir.Name.Equals(".vs", StringComparison.Ordinal) ||
subdir.Name.Equals(".vscode", StringComparison.Ordinal) ||
subdir.Name.Equals(".idea", StringComparison.Ordinal))
continue;
SetProgressDescription($"Scanning {subdir.FullName}..."); SetProgressDescription($"Scanning {subdir.FullName}...");
var normalizedSelf = subdir.FullName.Replace("\\", "/"); var normalizedSelf = subdir.FullName.Replace("\\", "/");
@ -110,7 +117,7 @@ namespace SourceGit.ViewModels
continue; continue;
} }
if (depth < 8) if (depth < 5)
GetUnmanagedRepositories(subdir, outs, opts, depth + 1); GetUnmanagedRepositories(subdir, outs, opts, depth + 1);
} }
} }