controller: code cleanups
This commit is contained in:
parent
351ad0df92
commit
8aa56d79a2
|
@ -251,7 +251,7 @@ 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) {
|
||||||
|
@ -271,13 +271,7 @@ namespace SparkleShare {
|
||||||
ProgressSpeed = "";
|
ProgressSpeed = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == SyncStatus.Idle ||
|
UpdateState ();
|
||||||
status == SyncStatus.SyncUp ||
|
|
||||||
status == SyncStatus.SyncDown ||
|
|
||||||
status == SyncStatus.Error) {
|
|
||||||
|
|
||||||
UpdateState ();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
repo.ProgressChanged += delegate (double percentage, string speed) {
|
repo.ProgressChanged += delegate (double percentage, string speed) {
|
||||||
|
@ -310,8 +304,8 @@ namespace SparkleShare {
|
||||||
if (repo.LocalPath.Equals (folder_path)) {
|
if (repo.LocalPath.Equals (folder_path)) {
|
||||||
repo.Dispose ();
|
repo.Dispose ();
|
||||||
this.repositories.Remove (repo);
|
this.repositories.Remove (repo);
|
||||||
|
|
||||||
repo = null;
|
repo = null;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,30 +367,22 @@ namespace SparkleShare {
|
||||||
// Fires events for the current syncing state
|
// Fires events for the current syncing state
|
||||||
private void UpdateState ()
|
private void UpdateState ()
|
||||||
{
|
{
|
||||||
bool has_syncing_repos = false;
|
|
||||||
bool has_unsynced_repos = false;
|
bool has_unsynced_repos = false;
|
||||||
|
|
||||||
foreach (SparkleRepoBase repo in Repositories) {
|
foreach (SparkleRepoBase repo in Repositories) {
|
||||||
if (repo.Status == SyncStatus.SyncDown ||
|
if (repo.Status == SyncStatus.SyncDown || repo.Status == SyncStatus.SyncUp || repo.IsBuffering) {
|
||||||
repo.Status == SyncStatus.SyncUp ||
|
OnSyncing ();
|
||||||
repo.IsBuffering) {
|
return;
|
||||||
|
|
||||||
has_syncing_repos = true;
|
|
||||||
|
|
||||||
} else if (repo.HasUnsyncedChanges) {
|
} else if (repo.HasUnsyncedChanges) {
|
||||||
has_unsynced_repos = true;
|
has_unsynced_repos = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_syncing_repos) {
|
if (has_unsynced_repos)
|
||||||
OnSyncing ();
|
|
||||||
|
|
||||||
} else if (has_unsynced_repos) {
|
|
||||||
OnError ();
|
OnError ();
|
||||||
|
else
|
||||||
} else {
|
|
||||||
OnIdle ();
|
OnIdle ();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -468,12 +454,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.fetcher = (SparkleFetcherBase) Activator.CreateInstance (
|
this.fetcher = (SparkleFetcherBase) Activator.CreateInstance (
|
||||||
Type.GetType ("SparkleLib." + backend + ".SparkleFetcher, SparkleLib." + backend),
|
Type.GetType ("SparkleLib." + backend + ".SparkleFetcher, SparkleLib." + backend),
|
||||||
address,
|
address, required_fingerprint, remote_path, tmp_folder, fetch_prior_history
|
||||||
required_fingerprint,
|
|
||||||
remote_path,
|
|
||||||
tmp_folder,
|
|
||||||
fetch_prior_history
|
|
||||||
);
|
);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in a new issue