repo: Fix race condition causing the statusicon to report an error where there isn't one
This commit is contained in:
parent
6c9df498ff
commit
4bd393828d
|
@ -158,8 +158,6 @@ namespace SparkleLib {
|
||||||
string identifier_file_path = Path.Combine (LocalPath, ".sparkleshare");
|
string identifier_file_path = Path.Combine (LocalPath, ".sparkleshare");
|
||||||
File.SetAttributes (identifier_file_path, FileAttributes.Hidden);
|
File.SetAttributes (identifier_file_path, FileAttributes.Hidden);
|
||||||
|
|
||||||
SyncStatusChanged += delegate (SyncStatus status) { Status = status; };
|
|
||||||
|
|
||||||
if (!UseCustomWatcher)
|
if (!UseCustomWatcher)
|
||||||
this.watcher = new SparkleWatcher (LocalPath);
|
this.watcher = new SparkleWatcher (LocalPath);
|
||||||
|
|
||||||
|
@ -277,7 +275,8 @@ namespace SparkleLib {
|
||||||
} while (HasLocalChanges);
|
} while (HasLocalChanges);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SyncStatusChanged (SyncStatus.Idle);
|
Status = SyncStatus.Idle;
|
||||||
|
SyncStatusChanged (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -334,7 +333,8 @@ namespace SparkleLib {
|
||||||
SparkleLogger.LogInfo ("SyncUp", Name + " | Initiated");
|
SparkleLogger.LogInfo ("SyncUp", Name + " | Initiated");
|
||||||
HasUnsyncedChanges = true;
|
HasUnsyncedChanges = true;
|
||||||
|
|
||||||
SyncStatusChanged (SyncStatus.SyncUp);
|
Status = SyncStatus.SyncUp;
|
||||||
|
SyncStatusChanged (Status);
|
||||||
|
|
||||||
if (SyncUp ()) {
|
if (SyncUp ()) {
|
||||||
SparkleLogger.LogInfo ("SyncUp", Name + " | Done");
|
SparkleLogger.LogInfo ("SyncUp", Name + " | Done");
|
||||||
|
@ -343,9 +343,11 @@ namespace SparkleLib {
|
||||||
HasUnsyncedChanges = false;
|
HasUnsyncedChanges = false;
|
||||||
this.poll_interval = PollInterval.Long;
|
this.poll_interval = PollInterval.Long;
|
||||||
|
|
||||||
SyncStatusChanged (SyncStatus.Idle);
|
|
||||||
this.listener.Announce (new SparkleAnnouncement (Identifier, CurrentRevision));
|
this.listener.Announce (new SparkleAnnouncement (Identifier, CurrentRevision));
|
||||||
|
|
||||||
|
Status = SyncStatus.Idle;
|
||||||
|
SyncStatusChanged (Status);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SparkleLogger.LogInfo ("SyncUp", Name + " | Error");
|
SparkleLogger.LogInfo ("SyncUp", Name + " | Error");
|
||||||
SyncDownBase ();
|
SyncDownBase ();
|
||||||
|
@ -357,11 +359,15 @@ namespace SparkleLib {
|
||||||
HasUnsyncedChanges = false;
|
HasUnsyncedChanges = false;
|
||||||
|
|
||||||
this.listener.Announce (new SparkleAnnouncement (Identifier, CurrentRevision));
|
this.listener.Announce (new SparkleAnnouncement (Identifier, CurrentRevision));
|
||||||
SyncStatusChanged (SyncStatus.Idle);
|
|
||||||
|
Status = SyncStatus.Idle;
|
||||||
|
SyncStatusChanged (Status);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.poll_interval = PollInterval.Short;
|
this.poll_interval = PollInterval.Short;
|
||||||
SyncStatusChanged (SyncStatus.Error);
|
|
||||||
|
Status = SyncStatus.Error;
|
||||||
|
SyncStatusChanged (Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +386,9 @@ namespace SparkleLib {
|
||||||
|
|
||||||
SparkleLogger.LogInfo ("SyncDown", Name + " | Initiated");
|
SparkleLogger.LogInfo ("SyncDown", Name + " | Initiated");
|
||||||
|
|
||||||
SyncStatusChanged (SyncStatus.SyncDown);
|
Status = SyncStatus.SyncDown;
|
||||||
|
SyncStatusChanged (Status);
|
||||||
|
|
||||||
string pre_sync_revision = CurrentRevision;
|
string pre_sync_revision = CurrentRevision;
|
||||||
|
|
||||||
if (SyncDown ()) {
|
if (SyncDown ()) {
|
||||||
|
@ -413,25 +421,30 @@ namespace SparkleLib {
|
||||||
// conflict. Tries only once, then lets
|
// conflict. Tries only once, then lets
|
||||||
// the timer try again periodically
|
// the timer try again periodically
|
||||||
if (HasUnsyncedChanges) {
|
if (HasUnsyncedChanges) {
|
||||||
SyncStatusChanged (SyncStatus.SyncUp);
|
Status = SyncStatus.SyncUp;
|
||||||
|
SyncStatusChanged (Status);
|
||||||
|
|
||||||
if (SyncUp ())
|
if (SyncUp ())
|
||||||
HasUnsyncedChanges = false;
|
HasUnsyncedChanges = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncStatusChanged (SyncStatus.Idle);
|
Status = SyncStatus.Idle;
|
||||||
|
SyncStatusChanged (Status);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SparkleLogger.LogInfo ("SyncDown", Name + " | Error");
|
SparkleLogger.LogInfo ("SyncDown", Name + " | Error");
|
||||||
|
|
||||||
ChangeSets = GetChangeSets ();
|
ChangeSets = GetChangeSets ();
|
||||||
SyncStatusChanged (SyncStatus.Error);
|
|
||||||
|
Status = SyncStatus.Error;
|
||||||
|
SyncStatusChanged (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressPercentage = 0.0;
|
ProgressPercentage = 0.0;
|
||||||
ProgressSpeed = 0.0;
|
ProgressSpeed = 0.0;
|
||||||
|
|
||||||
SyncStatusChanged (SyncStatus.Idle);
|
Status = SyncStatus.Idle;
|
||||||
|
SyncStatusChanged (Status);
|
||||||
|
|
||||||
if (!UseCustomWatcher)
|
if (!UseCustomWatcher)
|
||||||
this.watcher.Enable ();
|
this.watcher.Enable ();
|
||||||
|
|
|
@ -496,18 +496,21 @@ namespace SparkleShare {
|
||||||
private void UpdateState ()
|
private void UpdateState ()
|
||||||
{
|
{
|
||||||
bool has_unsynced_repos = false;
|
bool has_unsynced_repos = false;
|
||||||
|
bool has_syncing_repos = false;
|
||||||
|
|
||||||
foreach (SparkleRepoBase repo in Repositories) {
|
foreach (SparkleRepoBase repo in Repositories) {
|
||||||
if (repo.Status == SyncStatus.SyncDown || repo.Status == SyncStatus.SyncUp || repo.IsBuffering) {
|
if (repo.Status == SyncStatus.SyncDown || repo.Status == SyncStatus.SyncUp || repo.IsBuffering) {
|
||||||
OnSyncing ();
|
has_syncing_repos = true;
|
||||||
return;
|
break;
|
||||||
|
|
||||||
} else if (repo.HasUnsyncedChanges) {
|
} else if (repo.Status == SyncStatus.Idle && repo.HasUnsyncedChanges) {
|
||||||
has_unsynced_repos = true;
|
has_unsynced_repos = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_unsynced_repos)
|
if (has_syncing_repos)
|
||||||
|
OnSyncing ();
|
||||||
|
else if (has_unsynced_repos)
|
||||||
OnError ();
|
OnError ();
|
||||||
else
|
else
|
||||||
OnIdle ();
|
OnIdle ();
|
||||||
|
|
Loading…
Reference in a new issue