[ui] only specifically remove/add to the repo list, instead of throwing everything out
This commit is contained in:
parent
6357c95bcb
commit
6b518fdbaa
|
@ -75,18 +75,17 @@ namespace SparkleShare {
|
|||
Filter = "*"
|
||||
};
|
||||
|
||||
watcher.Deleted += delegate {
|
||||
watcher.Deleted += delegate (object o, FileSystemEventArgs args) {
|
||||
|
||||
foreach (SparkleRepo repo in Repositories)
|
||||
repo.Stop ();
|
||||
|
||||
Application.Invoke (delegate { UpdateRepositories (); } );
|
||||
RemoveRepository (args.FullPath);
|
||||
Application.Invoke (delegate { NotificationIcon.CreateMenu (); });
|
||||
|
||||
};
|
||||
|
||||
watcher.Created += delegate {
|
||||
watcher.Created += delegate (object o, FileSystemEventArgs args) {
|
||||
|
||||
Application.Invoke (delegate {UpdateRepositories (); } );
|
||||
AddRepository (args.FullPath);
|
||||
Application.Invoke (delegate { NotificationIcon.CreateMenu (); });
|
||||
|
||||
};
|
||||
|
||||
|
@ -323,19 +322,13 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
// Updates the list of repositories with all the
|
||||
// folders in the SparkleShare folder
|
||||
public void UpdateRepositories ()
|
||||
{
|
||||
|
||||
Repositories = new List <SparkleRepo> ();
|
||||
|
||||
foreach (string folder in Directory.GetDirectories (SparklePaths.SparklePath)) {
|
||||
public void AddRepository (string folder_path) {
|
||||
|
||||
// Check if the folder is a git repo
|
||||
if (Directory.Exists (SparkleHelpers.CombineMore (folder, ".git"))) {
|
||||
if (!Directory.Exists (SparkleHelpers.CombineMore (folder_path, ".git")))
|
||||
return;
|
||||
|
||||
SparkleRepo repo = new SparkleRepo (folder);
|
||||
SparkleRepo repo = new SparkleRepo (folder_path);
|
||||
|
||||
repo.NewCommit += delegate (object o, NewCommitArgs args) {
|
||||
Application.Invoke (delegate { ShowNewCommitBubble (args.Author, args.Email, args.Message); });
|
||||
|
@ -369,14 +362,44 @@ namespace SparkleShare {
|
|||
|
||||
}
|
||||
|
||||
|
||||
public void RemoveRepository (string folder_path) {
|
||||
|
||||
string repo_name = Path.GetFileName (folder_path);
|
||||
|
||||
foreach (SparkleRepo repo in Repositories) {
|
||||
|
||||
if (repo.Name.Equals (repo_name)) {
|
||||
|
||||
repo.Stop ();
|
||||
Repositories.Remove (repo);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Updates the list of repositories with all the
|
||||
// folders in the SparkleShare folder
|
||||
public void UpdateRepositories ()
|
||||
{
|
||||
|
||||
Repositories = new List <SparkleRepo> ();
|
||||
|
||||
foreach (string folder_path in Directory.GetDirectories (SparklePaths.SparklePath)) {
|
||||
|
||||
AddRepository (folder_path);
|
||||
|
||||
}
|
||||
|
||||
// Update the list in the statusicon
|
||||
if (NotificationIcon != null)
|
||||
NotificationIcon.CreateMenu ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Warns the user implicitly that unicorns are actually lethal creatures
|
||||
public static void CheckForUnicorns (string message) {
|
||||
|
|
Loading…
Reference in a new issue