fix: unblock windows preview updates
This commit is contained in:
parent
df7880c54b
commit
3e2bdbab7b
|
|
@ -14,7 +14,9 @@ use ratatui::{layout::Rect, Frame};
|
|||
#[cfg(test)]
|
||||
use tokio::sync::watch;
|
||||
use tokio::sync::{mpsc, Notify};
|
||||
use tracing::{debug, error, info, warn};
|
||||
#[cfg(not(windows))]
|
||||
use tracing::debug;
|
||||
use tracing::{error, info, warn};
|
||||
|
||||
use crate::detect::{Agent, AgentState};
|
||||
use crate::events::AppEvent;
|
||||
|
|
|
|||
|
|
@ -196,7 +196,8 @@ function Set-ManagedJunction {
|
|||
param(
|
||||
[string]$LinkPath,
|
||||
[string]$TargetPath,
|
||||
[string]$ManagedTargetPrefix
|
||||
[string]$ManagedTargetPrefix,
|
||||
[bool]$AllowLegacyHerdrBinMigration = $false
|
||||
)
|
||||
|
||||
if (Test-Path -LiteralPath $LinkPath) {
|
||||
|
|
@ -215,9 +216,12 @@ function Set-ManagedJunction {
|
|||
Remove-Item -LiteralPath $LinkPath -Force
|
||||
} elseif ($item.PSIsContainer) {
|
||||
if ((Get-ChildItem -LiteralPath $LinkPath -Force | Select-Object -First 1) -ne $null) {
|
||||
throw "Refusing to replace non-empty directory at $LinkPath with a junction."
|
||||
if (-not (Move-LegacyHerdrBinDirectory -Path $LinkPath -AllowMigration $AllowLegacyHerdrBinMigration)) {
|
||||
throw "Refusing to replace non-empty directory at $LinkPath with a junction."
|
||||
}
|
||||
} else {
|
||||
Remove-Item -LiteralPath $LinkPath -Force
|
||||
}
|
||||
Remove-Item -LiteralPath $LinkPath -Force
|
||||
} else {
|
||||
throw "Refusing to replace file at $LinkPath with a junction."
|
||||
}
|
||||
|
|
@ -227,6 +231,27 @@ function Set-ManagedJunction {
|
|||
New-Item -ItemType Junction -Path $LinkPath -Target $TargetPath | Out-Null
|
||||
}
|
||||
|
||||
function Move-LegacyHerdrBinDirectory {
|
||||
param(
|
||||
[string]$Path,
|
||||
[bool]$AllowMigration
|
||||
)
|
||||
|
||||
if (-not $AllowMigration) {
|
||||
return $false
|
||||
}
|
||||
|
||||
$entries = @(Get-ChildItem -LiteralPath $Path -Force)
|
||||
if ($entries.Count -ne 1 -or $entries[0].PSIsContainer -or $entries[0].Name -ine "herdr.exe") {
|
||||
return $false
|
||||
}
|
||||
|
||||
$legacyPath = "$Path.legacy.$([System.Guid]::NewGuid().ToString("N"))"
|
||||
Move-Item -LiteralPath $Path -Destination $legacyPath
|
||||
Write-Step "Moved legacy Herdr bin directory to $legacyPath."
|
||||
return $true
|
||||
}
|
||||
|
||||
function Remove-StaleInstallArtifacts {
|
||||
param([string]$ReleasesDir)
|
||||
|
||||
|
|
@ -396,6 +421,15 @@ $visibleBinDir = if ([string]::IsNullOrWhiteSpace($InstallDir)) {
|
|||
} else {
|
||||
$InstallDir
|
||||
}
|
||||
$allowLegacyVisibleBinMigration = $false
|
||||
try {
|
||||
$allowLegacyVisibleBinMigration = [System.IO.Path]::GetFullPath($visibleBinDir).TrimEnd("\").Equals(
|
||||
[System.IO.Path]::GetFullPath($defaultVisibleBinDir).TrimEnd("\"),
|
||||
[System.StringComparison]::OrdinalIgnoreCase
|
||||
)
|
||||
} catch {
|
||||
$allowLegacyVisibleBinMigration = $false
|
||||
}
|
||||
|
||||
$existingHerdr = Get-HerdrCommandSource
|
||||
if (-not [string]::IsNullOrWhiteSpace($existingHerdr) -and -not (Test-PathStartsWith -Path $existingHerdr -Prefix $visibleBinDir)) {
|
||||
|
|
@ -436,7 +470,7 @@ try {
|
|||
}
|
||||
|
||||
Set-ManagedJunction -LinkPath $currentDir -TargetPath $releaseDir -ManagedTargetPrefix $releasesDir
|
||||
Set-ManagedJunction -LinkPath $visibleBinDir -TargetPath $releaseDir -ManagedTargetPrefix $standaloneRoot
|
||||
Set-ManagedJunction -LinkPath $visibleBinDir -TargetPath $releaseDir -ManagedTargetPrefix $standaloneRoot -AllowLegacyHerdrBinMigration $allowLegacyVisibleBinMigration
|
||||
|
||||
$herdrCommand = Join-Path $visibleBinDir "herdr.exe"
|
||||
& $herdrCommand --version *> $null
|
||||
|
|
|
|||
Loading…
Reference in New Issue