Skip to content

Commit c85f46d

Browse files
committed
chore: clear cache data only when major / minor has increased
1 parent 138c21e commit c85f46d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/AppSettings.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ public static class AppSettings
1515
public static Version APP_VERSION = new Version("2.3.1");
1616
// Don't forget to put your Steam API key into the file "steam_api_key.txt"
1717
public static string STEAM_API_KEY = Properties.Resources.steam_api_key;
18-
// when an update needs to clear data cache, set it to true to prompt the user to save his comments
19-
public static bool REQUIRE_CLEAR_CACHE = true;
2018

2119
/// <summary>
2220
/// Return the Steam exe path from the registry

src/ViewModel/MainViewModel.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,15 @@ public RelayCommand WindowLoaded
111111
await _dialogService.ShowMessageAsync("It seems that CSGO is not installed on your main hard drive. The defaults \"csgo\" and \"replays\" can not be found. Please add folders from the settings.", MessageDialogStyle.Affirmative);
112112
}
113113

114-
// Check for 1st launch or upgrade that required cache clear
114+
// Check for 1st launch or upgrade that required cache clear (when app major / minor version > major / minor config version)
115115
if (_cacheService.ContainsDemos())
116116
{
117-
if ((string.IsNullOrEmpty(Properties.Settings.Default.ApplicationVersion) && AppSettings.REQUIRE_CLEAR_CACHE)
117+
if (string.IsNullOrEmpty(Properties.Settings.Default.ApplicationVersion)
118+
|| !string.IsNullOrEmpty(Properties.Settings.Default.ApplicationVersion)
119+
&& new Version(Properties.Settings.Default.ApplicationVersion).Major.CompareTo(AppSettings.APP_VERSION.Major) < 0
118120
|| (!string.IsNullOrEmpty(Properties.Settings.Default.ApplicationVersion)
119-
&& new Version(Properties.Settings.Default.ApplicationVersion).CompareTo(AppSettings.APP_VERSION) < 0
120-
&& AppSettings.REQUIRE_CLEAR_CACHE))
121+
&& new Version(Properties.Settings.Default.ApplicationVersion).Major.CompareTo(AppSettings.APP_VERSION.Major) == 0
122+
&& new Version(Properties.Settings.Default.ApplicationVersion).Minor.CompareTo(AppSettings.APP_VERSION.Minor) < 0))
121123
{
122124
var saveCustomData = await _dialogService.ShowMessageAsync("This update required to clear custom data from cache (your suspects list will not be removed). Do you want to save your custom data? ", MessageDialogStyle.AffirmativeAndNegative);
123125
if (saveCustomData == MessageDialogResult.Affirmative)

0 commit comments

Comments
 (0)