Archived
1
0

only create filter provider if download is complete

This commit is contained in:
2021-07-13 17:46:06 +02:00
parent 14c14f7626
commit 3eccbaa8b8
2 changed files with 21 additions and 8 deletions

View File

@@ -10,6 +10,10 @@ namespace NonaBGS.EDDB {
private string systems_file = null;
public delegate void DatabaseAvailableDelegate();
public event DatabaseAvailableDelegate SystemsAvailable;
public string SystemsFile => systems_file;
public string Cache {
@@ -27,13 +31,15 @@ namespace NonaBGS.EDDB {
client.DownloadDataCompleted += Client_DownloadDataCompleted;
}
private void DownloadFile(string url, string file) {
client.DownloadFileAsync(new Uri(url), file);
private void DownloadFile(string url, string file, DatabaseAvailableDelegate notifier) {
client.DownloadFileAsync(new Uri(url), file, notifier);
}
public void Download(bool force) {
if (!HaveSystemsFile || force) {
DownloadFile(EDDB_SYSTEMS_ARCHIVE, systems_file);
DownloadFile(EDDB_SYSTEMS_ARCHIVE, systems_file, SystemsAvailable);
} else if (HaveSystemsFile) {
SystemsAvailable?.Invoke();
}
}
@@ -54,6 +60,8 @@ namespace NonaBGS.EDDB {
}
private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) {
DatabaseAvailableDelegate notifier = e.UserState as DatabaseAvailableDelegate;
notifier?.Invoke();
}
}
}