mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-21 16:14:28 +08:00
fix.安装器AOT优化
This commit is contained in:
45
LanDesktopPLONDS.installer/Compress-NativeLibrary.ps1
Normal file
45
LanDesktopPLONDS.installer/Compress-NativeLibrary.ps1
Normal file
@@ -0,0 +1,45 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $SourcePath,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $DestinationPath
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$source = Get-Item -LiteralPath $SourcePath
|
||||
$destinationDirectory = Split-Path -Parent $DestinationPath
|
||||
New-Item -ItemType Directory -Path $destinationDirectory -Force | Out-Null
|
||||
|
||||
$existing = Get-Item -LiteralPath $DestinationPath -ErrorAction SilentlyContinue
|
||||
if ($existing -and $existing.LastWriteTimeUtc -ge $source.LastWriteTimeUtc -and $existing.Length -gt 0) {
|
||||
return
|
||||
}
|
||||
|
||||
$temporaryPath = "$DestinationPath.$PID.tmp"
|
||||
if (Test-Path -LiteralPath $temporaryPath) {
|
||||
Remove-Item -LiteralPath $temporaryPath -Force
|
||||
}
|
||||
|
||||
$inputStream = [System.IO.File]::OpenRead($source.FullName)
|
||||
try {
|
||||
$outputStream = [System.IO.File]::Create($temporaryPath)
|
||||
try {
|
||||
$gzipStream = New-Object System.IO.Compression.GZipStream($outputStream, [System.IO.Compression.CompressionMode]::Compress)
|
||||
try {
|
||||
$inputStream.CopyTo($gzipStream)
|
||||
}
|
||||
finally {
|
||||
$gzipStream.Dispose()
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$outputStream.Dispose()
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$inputStream.Dispose()
|
||||
}
|
||||
|
||||
Move-Item -LiteralPath $temporaryPath -Destination $DestinationPath -Force
|
||||
Reference in New Issue
Block a user