This commit is contained in:
2024-02-27 22:20:25 +02:00
parent a2179787b9
commit 3c3c6a1301
5 changed files with 24 additions and 19 deletions

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -94,7 +93,7 @@ public class Program
await StartNoGui();
try
{
internalActionManager = new InternalActionManager("./Data/Plugins", "*.dll");
internalActionManager = new InternalActionManager(AppSettings["PluginFolder"], "*.dll");
NoGUI();
}
catch (IOException ex)

View File

@@ -40,6 +40,8 @@ public class Config
AppSettings["PluginDatabase"] = "./Data/Resources/plugins.json";
ArchiveManager.Initialize();
if (!File.Exists(AppSettings["PluginDatabase"]))
{
List<PluginInfo> plugins = new();
@@ -62,7 +64,7 @@ public class Config
AppSettings["LogFolder"] + $"/{DateTime.Today.ToShortDateString().Replace("/", "")}.log"
);
ArchiveManager.Initialize();
UX.UxHandler.Init();
_isLoaded = true;

View File

@@ -1,16 +0,0 @@
using PluginManager.Interfaces.Updater;
namespace PluginManager.Online.Helpers;
public class ApplicationVersion: Version
{
public ApplicationVersion(int major, int minor, int patch): base(major, minor, patch)
{
}
public ApplicationVersion(string versionAsString): base(versionAsString)
{
}
}

View File

@@ -24,6 +24,24 @@ public static class ArchiveManager
IsInitialized = true;
}
public static async Task CreateFromFile(string file, string folder)
{
if(!IsInitialized) throw new Exception("ArchiveManager is not initialized");
if (!Directory.Exists(folder))
Directory.CreateDirectory(folder);
var archiveName = folder + Path.GetFileNameWithoutExtension(file) + ".zip";
if (File.Exists(archiveName))
File.Delete(archiveName);
using(ZipArchive archive = ZipFile.Open(archiveName, ZipArchiveMode.Create))
{
archive.CreateEntryFromFile(file, Path.GetFileName(file));
}
}
/// <summary>
/// Read a file from a zip archive. The output is a byte array
/// </summary>

View File

@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using PluginManager.Interfaces.Logger;
@@ -31,6 +32,7 @@ public sealed class Logger: ILogger
IsEnabled = true;
LowestLogLevel = lowestLogLevel;
OutputFile = null;
}
public event EventHandler<Log>? OnLog;