various rearrangements and tweaks

This commit is contained in:
Hylke Bons 2012-11-28 20:17:39 +00:00
parent d06de980c8
commit aea3176846
5 changed files with 40 additions and 47 deletions

View file

@ -42,13 +42,10 @@ namespace SparkleLib.Git {
SparkleGit git = new SparkleGit (TargetFolder, "ls-remote --heads"); SparkleGit git = new SparkleGit (TargetFolder, "ls-remote --heads");
string branches = git.StartAndReadStandardOutput (); string branches = git.StartAndReadStandardOutput ();
Regex salt_regex = new Regex ("refs/heads/salt-([0-9a-f]+)"); Regex salt_regex = new Regex ("refs/heads/salt-([0-9a-f]+)");
Match salt_match = salt_regex.Match (branches); Match salt_match = salt_regex.Match (branches);
if (salt_match.Success) { if (salt_match.Success)
this.cached_salt = salt_match.Groups [1].Value; this.cached_salt = salt_match.Groups [1].Value;
SparkleLogger.LogInfo ("SALT", salt_match.Groups [1].Value);
}
// ...if not, create a new salt for the repo // ...if not, create a new salt for the repo
if (string.IsNullOrEmpty (this.cached_salt)) { if (string.IsNullOrEmpty (this.cached_salt)) {

View file

@ -46,22 +46,23 @@ namespace SparkleLib.Git {
private string branch { private string branch {
get { get {
if (string.IsNullOrEmpty (this.cached_branch)) { if (!string.IsNullOrEmpty (this.cached_branch))
string rebase_apply_path = new string [] { LocalPath, ".git", "rebase-apply" }.Combine (); return this.cached_branch;
while (Directory.Exists (rebase_apply_path) && HasLocalChanges) { string rebase_apply_path = new string [] { LocalPath, ".git", "rebase-apply" }.Combine ();
try {
ResolveConflict (); while (Directory.Exists (rebase_apply_path) && HasLocalChanges) {
try {
} catch (IOException e) { ResolveConflict ();
SparkleLogger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again... (" + e.Message + ")");
} } catch (IOException e) {
SparkleLogger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again...", e);
} }
SparkleGit git = new SparkleGit (LocalPath, "rev-parse --abbrev-ref HEAD");
this.cached_branch = git.StartAndReadStandardOutput ();
} }
SparkleGit git = new SparkleGit (LocalPath, "rev-parse --abbrev-ref HEAD");
this.cached_branch = git.StartAndReadStandardOutput ();
return this.cached_branch; return this.cached_branch;
} }
} }
@ -480,7 +481,7 @@ namespace SparkleLib.Git {
ResolveConflict (); ResolveConflict ();
} catch (IOException e) { } catch (IOException e) {
SparkleLogger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again... (" + e.Message + ")"); SparkleLogger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again...", e);
} }
} }
@ -967,7 +968,7 @@ namespace SparkleLib.Git {
} }
} catch (IOException e) { } catch (IOException e) {
SparkleLogger.LogInfo ("Git", "Failed preparing directory: " + e.Message); SparkleLogger.LogInfo ("Git", "Failed preparing directory", e);
} }
} }
@ -1043,7 +1044,7 @@ namespace SparkleLib.Git {
} }
} catch (Exception e) { } catch (Exception e) {
SparkleLogger.LogInfo ("Local", "Error calculating size: " + e.Message); SparkleLogger.LogInfo ("Local", "Error calculating size", e);
return 0; return 0;
} }
@ -1053,7 +1054,7 @@ namespace SparkleLib.Git {
size += CalculateSizes (directory); size += CalculateSizes (directory);
} catch (Exception e) { } catch (Exception e) {
SparkleLogger.LogInfo ("Local", "Error calculating size: " + e.Message); SparkleLogger.LogInfo ("Local", "Error calculating size", e);
return 0; return 0;
} }

View file

@ -147,6 +147,8 @@ namespace SparkleLib {
public SparkleRepoBase (string path, SparkleConfig config) public SparkleRepoBase (string path, SparkleConfig config)
{ {
SparkleLogger.LogInfo (path, "Initializing...");
Status = SyncStatus.Idle; Status = SyncStatus.Idle;
Error = ErrorStatus.None; Error = ErrorStatus.None;
this.local_config = config; this.local_config = config;

View file

@ -386,13 +386,10 @@ namespace SparkleShare {
try { try {
repo = (SparkleRepoBase) Activator.CreateInstance ( repo = (SparkleRepoBase) Activator.CreateInstance (
Type.GetType ("SparkleLib." + backend + ".SparkleRepo, SparkleLib." + backend), Type.GetType ("SparkleLib." + backend + ".SparkleRepo, SparkleLib." + backend),
new object [] { folder_path, this.config } new object [] { folder_path, this.config });
);
} catch (Exception e) { } catch (Exception e) {
SparkleLogger.LogInfo ("Controller", SparkleLogger.LogInfo ("Controller", "Failed to load backend '" + backend + "' for '" + folder_name + "': ", e);
"Failed to load '" + backend + "' backend for '" + folder_name + "': " + e.Message);
return; return;
} }

View file

@ -93,18 +93,18 @@ namespace SparkleShare {
} }
} }
public bool QuitItemEnabled {
get {
return (CurrentState == IconState.Idle || CurrentState == IconState.Error);
}
}
public bool RecentEventsItemEnabled { public bool RecentEventsItemEnabled {
get { get {
return (Program.Controller.Folders.Count > 0); return (Program.Controller.Folders.Count > 0);
} }
} }
public bool QuitItemEnabled {
get {
return (CurrentState == IconState.Idle || CurrentState == IconState.Error);
}
}
public SparkleStatusIconController () public SparkleStatusIconController ()
{ {
@ -138,8 +138,6 @@ namespace SparkleShare {
StateText = "Projects up to date " + FolderSize; StateText = "Projects up to date " + FolderSize;
} }
UpdateQuitItemEvent (QuitItemEnabled);
UpdateStatusItemEvent (StateText);
UpdateIconEvent (CurrentState); UpdateIconEvent (CurrentState);
UpdateMenuEvent (CurrentState); UpdateMenuEvent (CurrentState);
}; };
@ -185,8 +183,6 @@ namespace SparkleShare {
UpdateFolders (); UpdateFolders ();
UpdateQuitItemEvent (QuitItemEnabled);
UpdateStatusItemEvent (StateText);
UpdateIconEvent (CurrentState); UpdateIconEvent (CurrentState);
UpdateMenuEvent (CurrentState); UpdateMenuEvent (CurrentState);
}; };
@ -206,6 +202,18 @@ namespace SparkleShare {
new Thread (() => repo.ForceRetry ()).Start (); new Thread (() => repo.ForceRetry ()).Start ();
} }
public EventHandler OpenFolderDelegate (string subfolder)
{
return delegate { SubfolderClicked (subfolder); };
}
public EventHandler TryAgainDelegate (string subfolder)
{
return delegate { TryAgainClicked (subfolder); };
}
public void RecentEventsClicked (object sender, EventArgs args) public void RecentEventsClicked (object sender, EventArgs args)
{ {
@ -237,18 +245,6 @@ namespace SparkleShare {
} }
public EventHandler OpenFolderDelegate (string subfolder)
{
return delegate { SubfolderClicked (subfolder); };
}
public EventHandler TryAgainDelegate (string subfolder)
{
return delegate { TryAgainClicked (subfolder); };
}
private void UpdateFolders () private void UpdateFolders ()
{ {
Folders = Program.Controller.Folders.ToArray (); Folders = Program.Controller.Folders.ToArray ();