Implemented Artemis.Web.Update client

This commit is contained in:
Robert committed 2023-02-12 16:48:16 +01:00
1 parent a5d2249593
commit 0cd65a2ebf
36 files changed
+1022 -359

No files matched your search

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
namespace Artemis.Core;
/// <summary>
/// Provides data about application update events
/// </summary>
public class UpdateEventArgs : EventArgs
{
internal UpdateEventArgs(bool silent)
{
Silent = silent;
}
/// <summary>
/// Gets a boolean indicating whether to silently update or not.
/// </summary>
public bool Silent { get; }
}
@@ -84,7 +84,20 @@ internal class PluginManagementService : IPluginManagementService
foreach (FileInfo zipFile in builtInPluginDirectory.EnumerateFiles("*.zip"))
{
// Find the metadata file in the zip
try
{
ExtractBuiltInPlugin(zipFile, pluginDirectory);
}
catch (Exception e)
{
_logger.Error(e, "Failed to copy built-in plugin from {ZipFile}", zipFile.FullName);
}
}
}
private void ExtractBuiltInPlugin(FileInfo zipFile, DirectoryInfo pluginDirectory)
{
// Find the metadata file in the zip
using ZipArchive archive = ZipFile.OpenRead(zipFile.FullName);
ZipArchiveEntry? metaDataFileEntry = archive.GetEntry("plugin.json");
if (metaDataFileEntry == null)
@@ -135,7 +148,6 @@ internal class PluginManagementService : IPluginManagementService
}
}
}
}
}
#endregion
+20 -1
View File
@@ -50,6 +50,15 @@ public static class Utilities
OnRestartRequested(new RestartEventArgs(elevate, delay, extraArgs.ToList()));
}
/// <summary>
/// Applies a pending update
/// </summary>
/// <param name="silent">A boolean indicating whether to silently update or not.</param>
public static void ApplyUpdate(bool silent)
{
OnUpdateRequested(new UpdateEventArgs(silent));
}
/// <summary>
/// Opens the provided URL in the default web browser
/// </summary>
@@ -96,11 +105,16 @@ public static class Utilities
/// Occurs when the core has requested an application shutdown
/// </summary>
public static event EventHandler? ShutdownRequested;
/// <summary>
/// Occurs when the core has requested an application restart
/// </summary>
public static event EventHandler<RestartEventArgs>? RestartRequested;
/// <summary>
/// Occurs when the core has requested a pending application update to be applied
/// </summary>
public static event EventHandler<UpdateEventArgs>? UpdateRequested;
/// <summary>
/// Opens the provided folder in the user's file explorer
@@ -136,6 +150,11 @@ public static class Utilities
{
ShutdownRequested?.Invoke(null, EventArgs.Empty);
}
private static void OnUpdateRequested(UpdateEventArgs e)
{
UpdateRequested?.Invoke(null, e);
}
#region Scaling