mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
feature: mark deleted repository and auto remove it after scan default clone dir (#576)
This commit is contained in:
parent
9668efbd8c
commit
0539a94cbe
4 changed files with 45 additions and 8 deletions
|
@ -453,6 +453,13 @@ namespace SourceGit.ViewModels
|
|||
Save();
|
||||
}
|
||||
|
||||
public void AutoRemoveInvalidNode()
|
||||
{
|
||||
var changed = RemoveInvalidRepositoriesRecursive(RepositoryNodes);
|
||||
if (changed)
|
||||
Save();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
if (_isLoading)
|
||||
|
@ -567,6 +574,27 @@ namespace SourceGit.ViewModels
|
|||
return false;
|
||||
}
|
||||
|
||||
private bool RemoveInvalidRepositoriesRecursive(List<RepositoryNode> collection)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
for (int i = collection.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var node = collection[i];
|
||||
if (node.IsInvalid)
|
||||
{
|
||||
collection.RemoveAt(i);
|
||||
changed = true;
|
||||
}
|
||||
else if (!node.IsRepository)
|
||||
{
|
||||
changed |= RemoveInvalidRepositoriesRecursive(node.SubNodes);
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static Preference _instance = null;
|
||||
private static bool _isLoading = false;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue