repo: remove unneeded try/catch block and fix up some logic

This commit is contained in:
Hylke Bons 2012-07-14 17:18:29 +02:00
parent c6347b4d78
commit 0839657282
2 changed files with 33 additions and 41 deletions

View file

@ -96,7 +96,7 @@ namespace SparkleLib.Git {
"\"" + RemoteUrl + "\" \"" + TargetFolder + "\""); "\"" + RemoteUrl + "\" \"" + TargetFolder + "\"");
} else { } else {
this.git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath, this.git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath,
"clone " + "clone " +
"--progress " + "--progress " +
"--no-checkout " + "--no-checkout " +

View file

@ -111,15 +111,14 @@ namespace SparkleLib {
} }
private string identifier; protected SparkleConfig local_config;
private string identifier;
private SparkleWatcher watcher; private SparkleWatcher watcher;
private SparkleListenerBase listener; private SparkleListenerBase listener;
private TimeSpan poll_interval = PollInterval.Short; private TimeSpan poll_interval = PollInterval.Short;
private DateTime last_poll = DateTime.Now;
private Object change_lock = new Object ();
private DateTime last_poll = DateTime.Now;
private Timers.Timer remote_timer = new Timers.Timer () { private Timers.Timer remote_timer = new Timers.Timer () {
Interval = 5000 Interval = 5000
@ -132,14 +131,11 @@ namespace SparkleLib {
} }
private static class PollInterval { private static class PollInterval {
public static TimeSpan Short { get { return new TimeSpan (0, 0, 5, 0); }} public static readonly TimeSpan Short = new TimeSpan (0, 0, 5, 0);
public static TimeSpan Long { get { return new TimeSpan (0, 0, 15, 0); }} public static readonly TimeSpan Long = new TimeSpan (0, 0, 15, 0);
} }
protected SparkleConfig local_config;
public SparkleRepoBase (string path, SparkleConfig config) public SparkleRepoBase (string path, SparkleConfig config)
{ {
this.local_config = config; this.local_config = config;
@ -275,17 +271,29 @@ namespace SparkleLib {
private void SyncUpBase () private void SyncUpBase ()
{ {
try { SparkleHelpers.DebugInfo ("SyncUp", Name + " | Initiated");
this.remote_timer.Stop (); HasUnsyncedChanges = true;
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Initiated"); this.remote_timer.Stop ();
if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.SyncUp);
if (SyncUp ()) {
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Done");
HasUnsyncedChanges = false;
if (SyncStatusChanged != null) if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.SyncUp); SyncStatusChanged (SyncStatus.Idle);
if (SyncUp ()) { this.listener.Announce (new SparkleAnnouncement (Identifier, CurrentRevision));
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Done");
} else {
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Error");
SyncDownBase ();
if (ServerOnline && SyncUp ()) {
HasUnsyncedChanges = false; HasUnsyncedChanges = false;
if (SyncStatusChanged != null) if (SyncStatusChanged != null)
@ -294,33 +302,17 @@ namespace SparkleLib {
this.listener.Announce (new SparkleAnnouncement (Identifier, CurrentRevision)); this.listener.Announce (new SparkleAnnouncement (Identifier, CurrentRevision));
} else { } else {
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Error"); ServerOnline = false;
HasUnsyncedChanges = true; if (SyncStatusChanged != null)
SyncDownBase (); SyncStatusChanged (SyncStatus.Error);
if (ServerOnline && SyncUp ()) {
HasUnsyncedChanges = false;
if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.Idle);
this.listener.Announce (new SparkleAnnouncement (Identifier, CurrentRevision));
} else {
ServerOnline = false;
if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.Error);
}
} }
} finally {
this.remote_timer.Start ();
ProgressPercentage = 0.0;
ProgressSpeed = "";
} }
this.remote_timer.Start ();
ProgressPercentage = 0.0;
ProgressSpeed = "";
} }