Skip to content

Commit 2f2ed4e

Browse files
author
Your Name
committed
Add debug output showing file modification times to verify updates
1 parent 2d4365d commit 2f2ed4e

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

install.ps1

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,14 @@ function Install-Binary {
238238
[string]$TargetPath
239239
)
240240

241+
# Debug: Show source file modification time
242+
if (Test-Path $SourcePath) {
243+
$sourceFile = Get-Item $SourcePath
244+
$sourceModTime = $sourceFile.LastWriteTime
245+
$timeSinceSource = (Get-Date) - $sourceModTime
246+
Write-Info "Source file modified: $sourceModTime ($([math]::Round($timeSinceSource.TotalMinutes, 1)) minutes ago)"
247+
}
248+
241249
# Stop running processes (simple, like OpenCode)
242250
$processes = Get-Process | Where-Object {
243251
($_.ProcessName -eq "pai") -or
@@ -252,8 +260,12 @@ function Install-Binary {
252260
Start-Sleep -Seconds 2
253261
}
254262

255-
# Remove old file if it exists (simple Remove-Item, like OpenCode's fs.rm)
263+
# Debug: Show existing target file modification time (if it exists)
256264
if (Test-Path $TargetPath) {
265+
$oldFile = Get-Item $TargetPath
266+
$oldModTime = $oldFile.LastWriteTime
267+
$timeSinceOld = (Get-Date) - $oldModTime
268+
Write-Info "Existing file modified: $oldModTime ($([math]::Round($timeSinceOld.TotalMinutes, 1)) minutes ago)"
257269
Write-Info "Removing existing file..."
258270
try {
259271
Remove-Item -Path $TargetPath -Force -ErrorAction Stop
@@ -267,7 +279,24 @@ function Install-Binary {
267279
Write-Info "Installing binary..."
268280
try {
269281
Move-Item -Path $SourcePath -Destination $TargetPath -Force -ErrorAction Stop
270-
Write-Success "Binary installed successfully"
282+
283+
# Debug: Verify installed file modification time
284+
Start-Sleep -Milliseconds 500 # Give Windows time to update metadata
285+
if (Test-Path $TargetPath) {
286+
$installedFile = Get-Item $TargetPath
287+
$installedModTime = $installedFile.LastWriteTime
288+
$timeSinceInstalled = (Get-Date) - $installedModTime
289+
Write-Info "Installed file modified: $installedModTime ($([math]::Round($timeSinceInstalled.TotalMinutes, 2)) minutes ago)"
290+
291+
# Warn if modification time is old (more than 2 minutes)
292+
if ($timeSinceInstalled.TotalMinutes -gt 2) {
293+
Write-Warning "WARNING: Installed file modification time is $([math]::Round($timeSinceInstalled.TotalMinutes, 1)) minutes old!"
294+
Write-Warning "This may indicate the file was not properly updated."
295+
} else {
296+
Write-Success "Binary installed successfully (file timestamp verified)"
297+
}
298+
}
299+
271300
return $true
272301
} catch {
273302
Write-Error "Installation failed: $_"

0 commit comments

Comments
 (0)