This commit is contained in:
2025-11-08 16:36:21 +01:00
parent 1a1d8a9337
commit 8779e306da
3 changed files with 44 additions and 4 deletions

View File

@@ -8,7 +8,7 @@
</PropertyGroup>
<PropertyGroup>
<Version>4.4.0</Version>
<Version>4.4.3</Version>
</PropertyGroup>
<ItemGroup>

View File

@@ -1,4 +1,6 @@
using System.IO.Compression;
using System.Diagnostics;
using System.IO.Compression;
using Pilz.Runtime;
namespace Pilz.Updating.Client;
@@ -26,6 +28,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
public bool UIDarkMode { get; set; }
public bool HasUpdates => UpdatePackageInfo != null;
public string? Distro { get; set; }
public bool MakeAppBinaryExecutable { get; set; } = RuntimeInformationsEx.OSType == OSType.Linux || RuntimeInformationsEx.OSType == OSType.Windows;
// E v e n t M e t h o d s
@@ -193,9 +196,28 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
Utils.CopyFiles(dataPathDir, destDir);
}
else if (package.UpdateType == UpdateType.File)
{
if (packageSource.PackageType == PackageType.File)
Utils.CopyFile(new FileInfo(dataPath), new FileInfo(localInstallPath));
else if (Directory.GetFiles(dataPath).FirstOrDefault() is { } firstFile)
Utils.CopyFile(new FileInfo(firstFile), new FileInfo(localInstallPath));
}
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PostEvent);
// Make executable
if (MakeAppBinaryExecutable)
{
switch (package.UpdateType)
{
case UpdateType.File:
Utils.MakeExecutable(localInstallPath);
break;
case UpdateType.Folder when !string.IsNullOrWhiteSpace(package.ExePath):
Utils.MakeExecutable(Path.Combine(localInstallPath, package.ExePath));
break;
}
}
// Delete Package
RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PreEvent);
if (packageSource.PackageType == PackageType.Zip)

View File

@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Pilz.Runtime;
namespace Pilz.Updating.Client;
@@ -68,4 +69,21 @@ public static class Utils
}
}
}
public static void MakeExecutable(string filePath)
{
var pChmod = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "chmod",
Arguments = $"+x \"{filePath}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
},
};
pChmod.Start();
pChmod.WaitForExit();
}
}