Merge claudedo/58764ab72f3e41e0871b9c81149ba1cc
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -75,7 +75,7 @@ public sealed partial class RepoImportModalViewModel : ViewModelBase
|
||||
ErrorReported?.Invoke(Loc.T("vm.repoImport.loadFailed", ex.Message));
|
||||
}
|
||||
|
||||
ScanAndAdd(_folders);
|
||||
await ScanAndAddAsync(_folders);
|
||||
OnPropertyChanged(nameof(HasFolders));
|
||||
NotifyCreateState();
|
||||
}
|
||||
@@ -88,20 +88,21 @@ public sealed partial class RepoImportModalViewModel : ViewModelBase
|
||||
|
||||
if (added.Count == 0) return;
|
||||
|
||||
ScanAndAdd(added);
|
||||
await ScanAndAddAsync(added);
|
||||
OnPropertyChanged(nameof(HasFolders));
|
||||
NotifyCreateState();
|
||||
await SaveFoldersAsync();
|
||||
}
|
||||
|
||||
private void ScanAndAdd(IEnumerable<string> folders)
|
||||
private async Task ScanAndAddAsync(IEnumerable<string> folders)
|
||||
{
|
||||
var current = new HashSet<string>(
|
||||
Repos.Select(r => r.FullPath), StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
foreach (var folder in folders)
|
||||
{
|
||||
foreach (var item in BuildCandidates(RepoScanner.Scan(folder), current, _existingDirs))
|
||||
var found = await Task.Run(() => RepoScanner.Scan(folder));
|
||||
foreach (var item in BuildCandidates(found, current, _existingDirs))
|
||||
{
|
||||
item.PropertyChanged += OnItemChanged;
|
||||
Repos.Add(item);
|
||||
|
||||
Reference in New Issue
Block a user