Skip to content

Commit 9716be2

Browse files
committed
Significant loading speed optimalization
Resolved issue with "All packages already installed" on second run Resolved freezing after using option "Download available packages" Improved overall stability
1 parent e0bfb9a commit 9716be2

File tree

11 files changed

+278
-120
lines changed

11 files changed

+278
-120
lines changed

RailworksDownloader/App.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ public partial class App : Application
3535

3636
internal static bool AutoDownload { get; set; } = true;
3737

38+
#if !DEBUG
3839
internal static bool Debug { get; set; } = false;
40+
#else
41+
internal static bool Debug { get; set; } = true;
42+
#endif
3943

4044
internal static bool ReportErrors { get; set; } = true;
4145

RailworksDownloader/DownloadDialog.xaml.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ public DownloadDialog(bool cancel = true)
2828
InitializeComponent();
2929
Title = Localization.Strings.PrepareTitle;
3030
CancelButton = cancel;
31+
Owner = App.Window;
3132
//FileName.Content = "";
3233
}
3334

34-
internal async Task UpdatePackages(Dictionary<int, int> update, List<Package> installedPackages, WebWrapper wrapper, SqLiteAdapter sqLiteAdapter)
35+
internal void UpdatePackages(Dictionary<int, int> update, List<Package> installedPackages, WebWrapper wrapper, SqLiteAdapter sqLiteAdapter)
3536
{
3637
for (int i = 0; i < update.Count; i++)
3738
{
@@ -49,10 +50,10 @@ internal async Task UpdatePackages(Dictionary<int, int> update, List<Package> in
4950

5051
try
5152
{
52-
ObjectResult<object> dl_result = await wrapper.DownloadPackage(pkgId, App.Token);
53+
ObjectResult<object> dl_result = wrapper.DownloadPackage(pkgId, App.Token);
5354

54-
if (WebWrapper.CancelDownload)
55-
return;
55+
/*if (WebWrapper.CancelDownload)
56+
return;*/
5657

5758
if (Utils.IsSuccessStatusCode(dl_result.code))
5859
{
@@ -74,14 +75,15 @@ internal async Task UpdatePackages(Dictionary<int, int> update, List<Package> in
7475
}
7576
else
7677
{
77-
if (dl_result.code > 0)
78+
if (dl_result.code > 0 && !WebWrapper.CancelDownload)
7879
{
7980
if (dl_result.code == 498)
8081
{
8182
App.Token = null;
8283
}
8384
Utils.DisplayError(Localization.Strings.DownloadError, dl_result.message);
8485
}
86+
File.Delete((string)dl_result.content);
8587
break;
8688
}
8789

@@ -97,7 +99,7 @@ internal async Task UpdatePackages(Dictionary<int, int> update, List<Package> in
9799
App.DialogQueue.RemoveDialog(this);
98100
}
99101

100-
internal async Task DownloadPackages(HashSet<int> download, List<Package> cached, List<Package> installedPackages, WebWrapper wrapper, SqLiteAdapter sqLiteAdapter)
102+
internal void DownloadPackages(HashSet<int> download, List<Package> cached, List<Package> installedPackages, WebWrapper wrapper, SqLiteAdapter sqLiteAdapter)
101103
{
102104
download.RemoveWhere(x => cached.Any(y => y.PackageId == x && (y.IsPaid || installedPackages.Any(z => z.PackageId == x))));
103105
int count = download.Count;
@@ -132,7 +134,7 @@ internal async Task DownloadPackages(HashSet<int> download, List<Package> cached
132134

133135
try
134136
{
135-
ObjectResult<object> dl_result = await wrapper.DownloadPackage(pkgId, App.Token);
137+
ObjectResult<object> dl_result = wrapper.DownloadPackage(pkgId, App.Token);
136138

137139
if (Utils.IsSuccessStatusCode(dl_result.code))
138140
{
@@ -147,14 +149,15 @@ internal async Task DownloadPackages(HashSet<int> download, List<Package> cached
147149
}
148150
else
149151
{
150-
if (dl_result.code > 0)
152+
if (dl_result.code > 0 && !WebWrapper.CancelDownload)
151153
{
152154
if (dl_result.code == 498)
153155
{
154156
App.Token = null;
155157
}
156158
Utils.DisplayError(Localization.Strings.DownloadError, dl_result.message);
157159
}
160+
File.Delete((string)dl_result.content);
158161
break;
159162
}
160163

@@ -274,13 +277,10 @@ private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDia
274277
{
275278
if (CancelButton)
276279
{
280+
App.Window.ScanRailworks.IsEnabled = true;
281+
App.Window.SelectRailworksLocation.IsEnabled = true;
282+
App.Window.DownloadMissing.IsEnabled = true;
277283
WebWrapper.CancelDownload = true;
278-
App.Window.Dispatcher.Invoke(() =>
279-
{
280-
App.Window.ScanRailworks.IsEnabled = true;
281-
App.Window.SelectRailworksLocation.IsEnabled = true;
282-
App.Window.DownloadMissing.IsEnabled = true;
283-
});
284284
}
285285
else
286286
args.Cancel = true;

RailworksDownloader/Localization/Strings.Designer.cs

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RailworksDownloader/Localization/Strings.cs.resx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@
246246
<data name="DLCReportError" xml:space="preserve">
247247
<value>Nastala neočekávaná chyba při hlášení nainstalovaných DLC!</value>
248248
</data>
249+
<data name="DLCReportWait" xml:space="preserve">
250+
<value>Čekám na dokončení DLC reportu...</value>
251+
</data>
249252
<data name="DownloadError" xml:space="preserve">
250253
<value>Nastala neočekávaná chyba při stahování</value>
251254
</data>
@@ -288,6 +291,18 @@
288291
<data name="FindFileFail" xml:space="preserve">
289292
<value>FindFile pro {0} vrátil prázdný výsledek!</value>
290293
</data>
294+
<data name="GettingAvailable" xml:space="preserve">
295+
<value>Hledání dostupných balíčků ke stažení...</value>
296+
</data>
297+
<data name="GettingInstalled" xml:space="preserve">
298+
<value>Procházení nainstalovaných souborů...</value>
299+
</data>
300+
<data name="GettingRequired" xml:space="preserve">
301+
<value>Vytváření seznamu potřebných závislostí...</value>
302+
</data>
303+
<data name="GettingStates" xml:space="preserve">
304+
<value>Procházení stavu závislostí...</value>
305+
</data>
291306
<data name="GzipEntryFail" xml:space="preserve">
292307
<value>Chyba při čtení gzip záznamu v souboru {0}!</value>
293308
</data>

RailworksDownloader/Localization/Strings.pl.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@
246246
<data name="DLCReportError" xml:space="preserve">
247247
<value>Podczas raportowania zainstalowanych DLC wystąpil nieoczekiwany błąd!</value>
248248
</data>
249+
<data name="DLCReportWait" xml:space="preserve">
250+
<value>Waiting for DLC report to finish...</value>
251+
</data>
249252
<data name="DownloadError" xml:space="preserve">
250253
<value>Wystąpil nieznany bląd przy pobieraniu</value>
251254
</data>
@@ -288,6 +291,15 @@
288291
<data name="FindFileFail" xml:space="preserve">
289292
<value>FindFile dla {0} nie istnieje!</value>
290293
</data>
294+
<data name="GettingInstalled" xml:space="preserve">
295+
<value>Getting all installed files...</value>
296+
</data>
297+
<data name="GettingRequired" xml:space="preserve">
298+
<value>Gettting all required files...</value>
299+
</data>
300+
<data name="GettingStates" xml:space="preserve">
301+
<value>Getting dependencies states...</value>
302+
</data>
291303
<data name="GzipEntryFail" xml:space="preserve">
292304
<value>Wystąpił błąd podczas próby czytania zapisu gzip pliku {0}!</value>
293305
</data>

RailworksDownloader/Localization/Strings.resx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@
246246
<data name="DLCReportError" xml:space="preserve">
247247
<value>There was an error while reporting installed DLS's!</value>
248248
</data>
249+
<data name="DLCReportWait" xml:space="preserve">
250+
<value>Waiting for DLC report to finish...</value>
251+
</data>
249252
<data name="DownloadError" xml:space="preserve">
250253
<value>Error occured while downloading</value>
251254
</data>
@@ -288,6 +291,18 @@
288291
<data name="FindFileFail" xml:space="preserve">
289292
<value>FindFile for {0} returned no packages!</value>
290293
</data>
294+
<data name="GettingAvailable" xml:space="preserve">
295+
<value>Getting available packages to download...</value>
296+
</data>
297+
<data name="GettingInstalled" xml:space="preserve">
298+
<value>Getting all installed files...</value>
299+
</data>
300+
<data name="GettingRequired" xml:space="preserve">
301+
<value>Gettting all required files...</value>
302+
</data>
303+
<data name="GettingStates" xml:space="preserve">
304+
<value>Getting dependencies states...</value>
305+
</data>
291306
<data name="GzipEntryFail" xml:space="preserve">
292307
<value>Error when reading gzip entry of file {0}!</value>
293308
</data>

0 commit comments

Comments
 (0)