Skip to content

Commit 2e18190

Browse files
steventuxCopilot
andcommitted
Check for storage directory and files before archiving
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent cb2ad4a commit 2e18190

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

scripts/powershell/maintenance.ps1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,26 @@ function Archive-PACS {
169169

170170
Write-Log "Archiving PACS files..." "INFO"
171171

172-
$pacsDir = Join-Path $BaseInstallPath "data\storage\*"
172+
$storageDir = Join-Path $BaseInstallPath "data\storage"
173173
$archiveZip = Join-Path $BaseInstallPath "data\storage.zip"
174174

175+
if (-not (Test-Path $storageDir)) {
176+
Write-Log "PACS storage directory not found: $storageDir" "WARNING"
177+
return
178+
}
179+
180+
$pacsDir = Join-Path $storageDir "*"
181+
$hasFiles = Get-ChildItem -Path $pacsDir -Force -ErrorAction SilentlyContinue | Select-Object -First 1
182+
if (-not $hasFiles) {
183+
Write-Log "No PACS files found to archive." "INFO"
184+
return
185+
}
186+
175187
Compress-Archive -Path $pacsDir -DestinationPath $archiveZip -Force
176188

177189
Write-Log "PACS files archived to $archiveZip." "INFO"
178190

179191
Remove-Item $pacsDir -Recurse -Force
180-
181192
Write-Log "PACS files removed from storage directory." "INFO"
182193

183194
Write-Log "PACS files archived successfully." "SUCCESS"

0 commit comments

Comments
 (0)