diff --git a/SPTInstaller/CustomControls/Dialogs/WhyCacheThoughDialog.axaml b/SPTInstaller/CustomControls/Dialogs/WhyCacheThoughDialog.axaml
index 79080f5..75cd47b 100644
--- a/SPTInstaller/CustomControls/Dialogs/WhyCacheThoughDialog.axaml
+++ b/SPTInstaller/CustomControls/Dialogs/WhyCacheThoughDialog.axaml
@@ -6,12 +6,12 @@
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SPTInstaller.CustomControls.Dialogs.WhyCacheThoughDialog">
-
-
+
The installer cache is used to ensure you don't re-download large files that you've already downloaded before.
You should only delete the cache folder if
- You are low on space
@@ -23,15 +23,26 @@ It also helps us prevent extra traffic to our limited download mirrors. Every bi
-
-
+
+
+
+
diff --git a/SPTInstaller/CustomControls/Dialogs/WhyCacheThoughDialog.axaml.cs b/SPTInstaller/CustomControls/Dialogs/WhyCacheThoughDialog.axaml.cs
index 57548f8..1807fe0 100644
--- a/SPTInstaller/CustomControls/Dialogs/WhyCacheThoughDialog.axaml.cs
+++ b/SPTInstaller/CustomControls/Dialogs/WhyCacheThoughDialog.axaml.cs
@@ -1,15 +1,41 @@
-using Avalonia.Controls;
-using SPTInstaller.Helpers;
+using SPTInstaller.Helpers;
using System.Diagnostics;
+using System.Linq;
+using Avalonia;
+using Avalonia.Controls;
+using Serilog;
namespace SPTInstaller.CustomControls.Dialogs;
public partial class WhyCacheThoughDialog : UserControl
{
+ private int _movePatcherState = 0;
+
+ private FileInfo? _foundPatcher;
+
public WhyCacheThoughDialog()
{
InitializeComponent();
}
+ public static readonly StyledProperty AdditionalInfoProperty =
+ AvaloniaProperty.Register(nameof(AdditionalInfo));
+
+ public string AdditionalInfo
+ {
+ get => GetValue(AdditionalInfoProperty);
+ set => SetValue(AdditionalInfoProperty, value);
+ }
+
+ public static readonly StyledProperty AdditionalInfoColorProperty =
+ AvaloniaProperty.Register(nameof(AdditionalInfoColor));
+
+ public string AdditionalInfoColor
+ {
+ get => GetValue(AdditionalInfoColorProperty);
+ set => SetValue(AdditionalInfoColorProperty, value);
+ }
+
+
public bool CacheExists => Directory.Exists(DownloadCacheHelper.CachePath);
public void OpenCacheFolder()
@@ -24,4 +50,55 @@ public partial class WhyCacheThoughDialog : UserControl
Verb = "open"
});
}
+
+ public void MoveDownloadsPatcherToCache()
+ {
+ switch (_movePatcherState)
+ {
+ case 0:
+ var downloadsPath =
+ Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
+
+ var downloadsFolder = new DirectoryInfo(downloadsPath);
+
+ if (!downloadsFolder.Exists)
+ {
+ AdditionalInfo = "Could not get downloads folder :(";
+ AdditionalInfoColor = "red";
+ _movePatcherState = -1;
+ return;
+ }
+
+ _foundPatcher = downloadsFolder.GetFiles("Patcher_*").FirstOrDefault();
+
+ if (_foundPatcher == null || !_foundPatcher.Exists)
+ {
+ AdditionalInfo =
+ "Could not find a patcher file in your downloads folder";
+
+ AdditionalInfoColor = "red";
+ return;
+ }
+
+ AdditionalInfo = $"Click again to move the below patcher file to the cache folder\n{_foundPatcher?.Name ?? "-SOMETHING WENT WRONG-"}";
+ AdditionalInfoColor = "#FFC107";
+ _movePatcherState = 1;
+ break;
+ case 1:
+ try
+ {
+ var cacheFilePath = Path.Join(DownloadCacheHelper.CachePath, "patcher");
+ _foundPatcher?.MoveTo(cacheFilePath, true);
+ AdditionalInfo = "Patch was moved into cache :D";
+ AdditionalInfoColor = "ForestGreen";
+ }
+ catch (Exception ex)
+ {
+ AdditionalInfo = "Something went wrong :(";
+ AdditionalInfoColor = "red";
+ Log.Error(ex, "Failed to move downloaded patcher file into cache");
+ }
+ break;
+ }
+ }
}