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

@ -111,14 +111,13 @@ 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 Object change_lock = new Object ();
private DateTime last_poll = DateTime.Now; private DateTime last_poll = DateTime.Now;
private Timers.Timer remote_timer = new Timers.Timer () { private Timers.Timer remote_timer = new Timers.Timer () {
@ -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,17 @@ namespace SparkleLib {
private void SyncUpBase () private void SyncUpBase ()
{ {
try {
this.remote_timer.Stop ();
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Initiated"); SparkleHelpers.DebugInfo ("SyncUp", Name + " | Initiated");
HasUnsyncedChanges = true;
this.remote_timer.Stop ();
if (SyncStatusChanged != null) if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.SyncUp); SyncStatusChanged (SyncStatus.SyncUp);
if (SyncUp ()) { if (SyncUp ()) {
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Done"); SparkleHelpers.DebugInfo ("SyncUp", Name + " | Done");
HasUnsyncedChanges = false; HasUnsyncedChanges = false;
if (SyncStatusChanged != null) if (SyncStatusChanged != null)
@ -295,8 +291,6 @@ namespace SparkleLib {
} else { } else {
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Error"); SparkleHelpers.DebugInfo ("SyncUp", Name + " | Error");
HasUnsyncedChanges = true;
SyncDownBase (); SyncDownBase ();
if (ServerOnline && SyncUp ()) { if (ServerOnline && SyncUp ()) {
@ -315,13 +309,11 @@ namespace SparkleLib {
} }
} }
} finally {
this.remote_timer.Start (); this.remote_timer.Start ();
ProgressPercentage = 0.0; ProgressPercentage = 0.0;
ProgressSpeed = ""; ProgressSpeed = "";
} }
}
private void SyncDownBase () private void SyncDownBase ()