diff --git a/EllieHub/Common/AppResources.cs b/EllieHub/Common/AppResources.cs
index fe8b56a..908a534 100644
--- a/EllieHub/Common/AppResources.cs
+++ b/EllieHub/Common/AppResources.cs
@@ -95,19 +95,16 @@ public static class AppResources
///
public const string LightBackground = "LightBackground";
-
///
/// Resource type:
///
public const string MediumBackground = "MediumBackground";
-
///
/// Resource type:
///
public const string HeavyBackground = "HeavyBackground";
-
///
/// Resource type:
///
diff --git a/EllieHub/EllieHub.csproj b/EllieHub/EllieHub.csproj
index 074b2fa..73d1c40 100644
--- a/EllieHub/EllieHub.csproj
+++ b/EllieHub/EllieHub.csproj
@@ -1,41 +1,42 @@
-
-
- WinExe
- net7.0
- latest
- latest
- enable
- enable
- Nullable
- True
- True
- True
- True
- Assets/Light/ellieupdatericon.ico
-
-
- true
- embedded
+
+
+ WinExe
+ net8.0
+ latest
+ latest
+ enable
+ enable
+ Nullable
+ True
+ True
+ True
+ True
+ Assets/Light/ellieupdatericon.ico
-
- 1.0.0.0
-
-
- app.manifest
- true
-
-
- true
-
+
+ true
+ true
+ embedded
-
-
+
+ 1.0.1.0
-
-
-
-
+
+ app.manifest
+ true
+
+
+ true
+
+
+
+
+
+
+
+
+
@@ -54,9 +55,9 @@
-
-
- AppView.axaml
-
-
+
+
+ AppView.axaml
+
+
\ No newline at end of file
diff --git a/EllieHub/Services/AppResolver.cs b/EllieHub/Services/AppResolver.cs
index 7ad4454..75157f3 100644
--- a/EllieHub/Services/AppResolver.cs
+++ b/EllieHub/Services/AppResolver.cs
@@ -23,7 +23,7 @@ public sealed class AppResolver : IAppResolver
///
public string FileName { get; }
-
+
///
public string BinaryUri { get; }
@@ -126,7 +126,7 @@ public sealed class AppResolver : IAppResolver
foreach (var newFileUri in newFilesUris)
{
var destinationUri = Path.Combine(AppContext.BaseDirectory, newFileUri[(newFileUri.LastIndexOf(Path.DirectorySeparatorChar) + 1)..]);
-
+
// Rename the original file from "file" to "file_old".
if (File.Exists(destinationUri))
File.Move(destinationUri, destinationUri + OldFileSuffix);
diff --git a/EllieHub/Services/EllieOrchestrator.cs b/EllieHub/Services/EllieOrchestrator.cs
index 2b05bd3..b871b16 100644
--- a/EllieHub/Services/EllieOrchestrator.cs
+++ b/EllieHub/Services/EllieOrchestrator.cs
@@ -30,12 +30,10 @@ public sealed class EllieOrchestrator : IBotOrchestrator
public EllieOrchestrator(ReadOnlyAppConfig appConfig)
=> _appConfig = appConfig;
-
///
public bool IsBotRunning(Guid botId)
=> _runningBots.ContainsKey(botId);
-
///
public bool Start(Guid botId)
{
diff --git a/EllieHub/Services/EllieResolver.cs b/EllieHub/Services/EllieResolver.cs
index 6e2f6cf..b3669e7 100644
--- a/EllieHub/Services/EllieResolver.cs
+++ b/EllieHub/Services/EllieResolver.cs
@@ -162,52 +162,15 @@ public sealed partial class EllieResolver : IBotResolver
cToken
);
- // Move the bot root directory while renaming it
+ // Move the bot root directory
if (Environment.OSVersion.Platform is not PlatformID.Unix)
- {
- // Save the zip file
- using (var fileStream = new FileStream(zipTempLocation, FileMode.Create))
- await downloadStream.CopyToAsync(fileStream, cToken);
-
- // Extract the zip file
- await Task.Run(() => ZipFile.ExtractToDirectory(zipTempLocation, _tempDirectory), cToken);
-
- // Move the bot root directory while renaming it
- Directory.Move(botTempLocation, installationUri);
- }
+ await InstallToWindowsAsync(downloadStream, installationUri, zipTempLocation, botTempLocation, cToken);
else
- {
- // Extract the tar ball
- await TarFile.ExtractToDirectoryAsync(downloadStream, _tempDirectory, true, cToken);
-
- // Move the bot root directory with "mv" to circumvent this issue on Unix systems: https://github.com/dotnet/runtime/issues/31149
- using var moveProcess = Utilities.StartProcess("mv", $"\"{botTempLocation}\" \"{installationUri}\"");
- await moveProcess.WaitForExitAsync(cToken);
-
- // Set executable permission
- using var chmod = Utilities.StartProcess("chmod", $"+x \"{Path.Combine(installationUri, FileName)}\"");
- await chmod.WaitForExitAsync(cToken);
- }
+ await InstallToUnixAsync(downloadStream, installationUri, botTempLocation, cToken);
// Reapply bot settings
if (File.Exists(backupFileUri))
- {
- using var zipFile = ZipFile.OpenRead(backupFileUri);
- var zippedFiles = zipFile.Entries
- .Where(x =>
- x.Name is "creds.yml" or "creds_example.yml"
- || (!string.IsNullOrWhiteSpace(x.Name) && x.FullName.Contains("data/"))
- );
-
- foreach (var zippedFile in zippedFiles)
- {
- var fileDestinationPath = zippedFile.FullName.Split('/')
- .Prepend(Directory.GetParent(installationUri)?.FullName ?? string.Empty)
- .ToArray();
-
- await RestoreFileAsync(zippedFile, Path.Combine(fileDestinationPath), cToken);
- }
- }
+ await ReaplyBotSettingsAsync(installationUri, backupFileUri, cToken);
// Update settings
await _appConfigManager.UpdateBotEntryAsync(Id, x => x with { Version = latestVersion }, cToken);
@@ -230,6 +193,73 @@ public sealed partial class EllieResolver : IBotResolver
}
}
+ ///
+ /// Installs the Nadeko instance on a Unix system.
+ ///
+ /// The stream of data downloaded from the source.
+ /// The absolute path to the directory the bot got installed to.
+ /// The absolute path to the temporary directory the bot is extracted to.
+ /// The cancellation token.
+ private async ValueTask InstallToUnixAsync(Stream downloadStream, string installationUri, string botTempLocation, CancellationToken cToken = default)
+ {
+ // Extract the tar ball
+ await TarFile.ExtractToDirectoryAsync(downloadStream, _tempDirectory, true, cToken);
+
+ // Move the bot root directory with "mv" to circumvent this issue on Unix systems: https://github.com/dotnet/runtime/issues/31149
+ using var moveProcess = Utilities.StartProcess("mv", $"\"{botTempLocation}\" \"{installationUri}\"");
+ await moveProcess.WaitForExitAsync(cToken);
+
+ // Set executable permission
+ using var chmod = Utilities.StartProcess("chmod", $"+x \"{Path.Combine(installationUri, FileName)}\"");
+ await chmod.WaitForExitAsync(cToken);
+ }
+
+ ///
+ /// Installs the Nadeko instance on a non-Unix system.
+ ///
+ /// The stream of data downloaded from the source.
+ /// The absolute path to the directory the bot got installed to.
+ /// The absolute path to the zip file the bot is initially on.
+ /// The absolute path to the temporary directory the bot is extracted to.
+ /// The cancellation token.
+ private async static ValueTask InstallToWindowsAsync(Stream downloadStream, string installationUri, string zipTempLocation, string botTempLocation, CancellationToken cToken = default)
+ {
+ // Save the zip file
+ using (var fileStream = new FileStream(zipTempLocation, FileMode.Create))
+ await downloadStream.CopyToAsync(fileStream, cToken);
+
+ // Extract the zip file
+ await Task.Run(() => ZipFile.ExtractToDirectory(zipTempLocation, _tempDirectory), cToken);
+
+ // Move the bot root directory while renaming it
+ Directory.Move(botTempLocation, installationUri);
+ }
+
+ ///
+ /// Reaplies the bot settings and user-defined data from the specified backup.
+ ///
+ /// The absolute path to the directory the bot got installed to.
+ /// The absolute path to the backup zip file.
+ /// The cancellation token.
+ private async static ValueTask ReaplyBotSettingsAsync(string installationUri, string backupFileUri, CancellationToken cToken = default)
+ {
+ using var zipFile = ZipFile.OpenRead(backupFileUri);
+ var zippedFiles = zipFile.Entries
+ .Where(x =>
+ x.Name is "creds.yml" or "creds_example.yml"
+ || (!string.IsNullOrWhiteSpace(x.Name) && x.FullName.Contains("data/"))
+ );
+
+ foreach (var zippedFile in zippedFiles)
+ {
+ var fileDestinationPath = zippedFile.FullName.Split('/')
+ .Prepend(Directory.GetParent(installationUri)?.FullName ?? string.Empty)
+ .ToArray();
+
+ await RestoreFileAsync(zippedFile, Path.Combine(fileDestinationPath), cToken);
+ }
+ }
+
///
/// Extracts the specified to the .
///
diff --git a/EllieHub/Services/LogWriter.cs b/EllieHub/Services/LogWriter.cs
index 60f519c..23cd9d4 100644
--- a/EllieHub/Services/LogWriter.cs
+++ b/EllieHub/Services/LogWriter.cs
@@ -48,7 +48,7 @@ public sealed class LogWriter : ILogWriter
var botEntry = _appConfig.BotEntries[botId];
var now = DateTimeOffset.Now;
var date = new DateOnly(now.Year, now.Month, now.Day).ToShortDateString().Replace('/', '-');
- var fileUri = Path.Combine(_appConfig.LogsDirectoryUri, $"{botEntry.Name}_{date}-{now.ToUnixTimeSeconds()}.txt");
+ var fileUri = Path.Combine(_appConfig.LogsDirectoryUri, $"{botEntry.Name}_v{botEntry.Version}_{date}-{now.ToUnixTimeSeconds()}.txt");
await File.WriteAllTextAsync(fileUri, logStringBuilder.ToString(), cToken);
diff --git a/EllieHub/ViewModels/Controls/BotConfigViewModel.cs b/EllieHub/ViewModels/Controls/BotConfigViewModel.cs
index edf30ba..af6c6ec 100644
--- a/EllieHub/ViewModels/Controls/BotConfigViewModel.cs
+++ b/EllieHub/ViewModels/Controls/BotConfigViewModel.cs
@@ -10,7 +10,6 @@ using ReactiveUI;
using SkiaSharp;
using System.Diagnostics;
using System.Reactive.Disposables;
-using System.Runtime.InteropServices;
namespace EllieHub.ViewModels.Controls;
diff --git a/EllieHub/ViewModels/Controls/ConfigViewModel.cs b/EllieHub/ViewModels/Controls/ConfigViewModel.cs
index 1293e60..7510ad9 100644
--- a/EllieHub/ViewModels/Controls/ConfigViewModel.cs
+++ b/EllieHub/ViewModels/Controls/ConfigViewModel.cs
@@ -1,4 +1,3 @@
-using Avalonia;
using Avalonia.Controls;
using Avalonia.Styling;
using MsBox.Avalonia.Enums;