File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -170,15 +170,26 @@ function Archive-PACS {
170170
171171 Write-Log " Archiving PACS files..." " INFO"
172172
173- $pacsDir = Join-Path $BaseInstallPath " data\storage\* "
173+ $storageDir = Join-Path $BaseInstallPath " data\storage"
174174 $archiveZip = Join-Path $BaseInstallPath " data\storage.zip"
175175
176+ if (-not (Test-Path $storageDir )) {
177+ Write-Log " PACS storage directory not found: $storageDir " " WARNING"
178+ return
179+ }
180+
181+ $pacsDir = Join-Path $storageDir " *"
182+ $hasFiles = Get-ChildItem - Path $pacsDir - Force - ErrorAction SilentlyContinue | Select-Object - First 1
183+ if (-not $hasFiles ) {
184+ Write-Log " No PACS files found to archive." " INFO"
185+ return
186+ }
187+
176188 Compress-Archive - Path $pacsDir - DestinationPath $archiveZip - Force
177189
178190 Write-Log " PACS files archived to $archiveZip ." " INFO"
179191
180192 Remove-Item $pacsDir - Recurse - Force
181-
182193 Write-Log " PACS files removed from storage directory." " INFO"
183194
184195 Write-Log " PACS files archived successfully." " SUCCESS"
You can’t perform that action at this time.
0 commit comments