mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
When updating, bypass execution policy for scripts
Fix getting stuck on Initializing Core if updating fails
This commit is contained in:
parent
d8390d306c
commit
8dee02e6fd
@ -142,7 +142,7 @@ public class ApplicationStateManager
|
|||||||
string redirectSymbol = File.Exists(outputFile) && new FileInfo(outputFile).Length > 200000 ? ">" : ">>";
|
string redirectSymbol = File.Exists(outputFile) && new FileInfo(outputFile).Length > 200000 ? ">" : ">>";
|
||||||
ProcessStartInfo info = new()
|
ProcessStartInfo info = new()
|
||||||
{
|
{
|
||||||
Arguments = $"PowerShell -File \"{script}\" {arguments} {redirectSymbol} \"{outputFile}\"",
|
Arguments = $"PowerShell -ExecutionPolicy Bypass -File \"{script}\" {arguments} {redirectSymbol} \"{outputFile}\"",
|
||||||
FileName = "PowerShell.exe",
|
FileName = "PowerShell.exe",
|
||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
|
|||||||
@ -26,20 +26,21 @@ if ($process)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Check if the destination directory exists
|
# Check if the destination directory exists
|
||||||
if (!(Test-Path $destinationDirectory))
|
if (!(Test-Path "$destinationDirectory"))
|
||||||
{
|
{
|
||||||
Write-Error "The destination directory does not exist"
|
Write-Error "The destination directory does not exist"
|
||||||
|
Exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clear the destination directory but don't remove it, leaving ACL entries in tact
|
# Clear the destination directory but don't remove it, leaving ACL entries in tact
|
||||||
Write-Host "Cleaning up old version where needed"
|
Write-Host "Cleaning up old version where needed"
|
||||||
Get-ChildItem $destinationDirectory | Remove-Item -Recurse -Force
|
Get-ChildItem "$destinationDirectory" | Remove-Item -Recurse -Force
|
||||||
|
|
||||||
# Move the contents of the source directory to the destination directory
|
# Move the contents of the source directory to the destination directory
|
||||||
Write-Host "Installing new files"
|
Write-Host "Installing new files"
|
||||||
Get-ChildItem $sourceDirectory | Move-Item -Destination $destinationDirectory
|
Get-ChildItem "$sourceDirectory" | Move-Item -Destination "$destinationDirectory"
|
||||||
# Remove the now empty source directory
|
# Remove the now empty source directory
|
||||||
Remove-Item $sourceDirectory
|
Remove-Item "$sourceDirectory"
|
||||||
|
|
||||||
Write-Host "Finished! Restarting Artemis"
|
Write-Host "Finished! Restarting Artemis"
|
||||||
Start-Sleep -Seconds 1
|
Start-Sleep -Seconds 1
|
||||||
@ -47,9 +48,9 @@ Start-Sleep -Seconds 1
|
|||||||
# When finished, run the updated version
|
# When finished, run the updated version
|
||||||
if ($artemisArgs)
|
if ($artemisArgs)
|
||||||
{
|
{
|
||||||
Start-Process -FilePath "$destinationDirectory\Artemis.UI.Windows.exe" -WorkingDirectory $destinationDirectory -ArgumentList $artemisArgs
|
Start-Process -FilePath "$destinationDirectory\Artemis.UI.Windows.exe" -WorkingDirectory "$destinationDirectory" -ArgumentList $artemisArgs
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Start-Process -FilePath "$destinationDirectory\Artemis.UI.Windows.exe" -WorkingDirectory $destinationDirectory
|
Start-Process -FilePath "$destinationDirectory\Artemis.UI.Windows.exe" -WorkingDirectory "$destinationDirectory"
|
||||||
}
|
}
|
||||||
@ -205,15 +205,22 @@ public class UpdateService : IUpdateService
|
|||||||
{
|
{
|
||||||
_logger.Error(e, "Failed to delete leftover installing folder");
|
_logger.Error(e, "Failed to delete leftover installing folder");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If an update is pending, don't bother with anything else
|
// If an update is pending, don't bother with anything else
|
||||||
if (Directory.Exists(Path.Combine(Constants.UpdatingFolder, "pending")))
|
if (Directory.Exists(Path.Combine(Constants.UpdatingFolder, "pending")))
|
||||||
{
|
{
|
||||||
_logger.Information("Installing pending update");
|
_logger.Information("Installing pending update");
|
||||||
RestartForUpdate(true);
|
try
|
||||||
return true;
|
{
|
||||||
|
RestartForUpdate(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.Warning(e, "Failed to apply pending update");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessReleaseStatus();
|
ProcessReleaseStatus();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user