Permalink
Browse files

statusicon: add lock. attempt to fix #1130

  • Loading branch information...
hbons committed Jan 5, 2013
1 parent 0361693 commit 037951b967e8940e8efc816cac202934a363874c
Showing with 31 additions and 27 deletions.
  1. +1 −1 SparkleShare/SparkleControllerBase.cs
  2. +30 −26 SparkleShare/SparkleStatusIconController.cs
@@ -262,7 +262,7 @@ public void UIHasLoaded ()
new Thread (() => {
string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
- string key_file_name = DateTime.Now.ToString ("yyyy-MM-dd_HH\\hmm"); // TODO: move to undercore name for old keys
+ string key_file_name = DateTime.Now.ToString ("yyyy-MM-dd_HH\\hmm");
string [] key_pair = SparkleKeys.GenerateKeyPair (keys_path, key_file_name);
SparkleKeys.ImportPrivateKey (key_pair [0]);
@@ -248,39 +248,43 @@ public void QuitClicked ()
}
+ private Object folders_lock = new Object ();
+
private void UpdateFolders ()
{
- List<string> folders = new List<string> ();
- List<string> folder_errors = new List<string> ();
+ lock (this.folders_lock) {
+ List<string> folders = new List<string> ();
+ List<string> folder_errors = new List<string> ();
- foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
- folders.Add (repo.Name);
-
- if (repo.Error == ErrorStatus.HostUnreachable) {
- folder_errors.Add ("Can't reach the host");
-
- } else if (repo.Error == ErrorStatus.HostIdentityChanged) {
- folder_errors.Add ("The host's identity has changed");
-
- } else if (repo.Error == ErrorStatus.AuthenticationFailed) {
- folder_errors.Add ("Authentication failed");
+ foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
+ folders.Add (repo.Name);
- } else if (repo.Error == ErrorStatus.DiskSpaceExceeded) {
- folder_errors.Add ("Host is out of disk space");
-
- } else if (repo.Error == ErrorStatus.LockedFiles) {
- folder_errors.Add ("Some local files are locked or in use");
+ if (repo.Error == ErrorStatus.HostUnreachable) {
+ folder_errors.Add ("Can't reach the host");
+
+ } else if (repo.Error == ErrorStatus.HostIdentityChanged) {
+ folder_errors.Add ("The host's identity has changed");
+
+ } else if (repo.Error == ErrorStatus.AuthenticationFailed) {
+ folder_errors.Add ("Authentication failed");
+
+ } else if (repo.Error == ErrorStatus.DiskSpaceExceeded) {
+ folder_errors.Add ("Host is out of disk space");
+
+ } else if (repo.Error == ErrorStatus.LockedFiles) {
+ folder_errors.Add ("Some local files are locked or in use");
- } else if (repo.Error == ErrorStatus.NotFound) {
- folder_errors.Add ("Project doesn't exist on host");
-
- } else {
- folder_errors.Add ("");
+ } else if (repo.Error == ErrorStatus.NotFound) {
+ folder_errors.Add ("Project doesn't exist on host");
+
+ } else {
+ folder_errors.Add ("");
+ }
}
- }
- Folders = folders.ToArray ();
- FolderErrors = folder_errors.ToArray ();
+ Folders = folders.ToArray ();
+ FolderErrors = folder_errors.ToArray ();
+ }
}
}
}

0 comments on commit 037951b

Please sign in to comment.