فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
fix(a02): use explicit WinPS5-compatible constructors and single-result SQL catalog query
davoodmehraban89 committed
Oct 30, 2026 at 19:02 UTC
242530c5b235a0abd49e8cf19174bc5cfaf632da
1 file changed
+4
-9
scripts/a02-isolated-sql-restore.ps1
+4
-9
@@ -43,7 +43,7 @@ function Assert-LocalPathShape([string]$Value) {
43
44
function Assert-LocalFilesystemSource([string]$Value) {
45
$path = Assert-LocalPathShape $Value
46
- $drive = New-Object System.IO.DriveInfo($path.Substring(0, 1))
46
+ $drive = [System.IO.DriveInfo]::new($path.Substring(0, 1))
47
if ($drive.DriveType -ne [System.IO.DriveType]::Fixed -and
48
$drive.DriveType -ne [System.IO.DriveType]::Removable) {
49
throw 'A02_SOURCE_NOT_LOCAL_DISK'
@@ -87,7 +87,7 @@ function New-LocalRestorePlan(
87
if ($null -eq $Files -or $Files.Count -lt 2 -or $Files.Count -gt 16) {
88
throw 'A02_FILELIST_COUNT_UNSUPPORTED'
89
}
90
- $seen = New-Object 'System.Collections.Generic.HashSet[string]' (
90
+ $seen = [System.Collections.Generic.HashSet[string]]::new(
91
[System.StringComparer]::OrdinalIgnoreCase
92
)
93
$moves = @()
@@ -174,12 +174,7 @@ function Invoke-SqlCommand($Connection, [string]$Sql, [int]$Timeout = 1800) {
174
175
function Assert-PlanCollisionFree($Connection, $Plan) {
176
# Only read system catalogs; no CREATE/DROP/ALTER.
177
- $catalog = Invoke-SqlRows $Connection (
178
- 'SELECT name, physical_name FROM sys.master_files;' +
179
- 'SELECT name FROM sys.databases;'
180
- )
181
- # DataAdapter.Fill reads only its first result table. Query DB existence
182
- # separately so a surprising result layout cannot silently pass.
177
+ $catalog = Invoke-SqlRows $Connection 'SELECT physical_name FROM sys.master_files'
178
$names = Invoke-SqlRows $Connection 'SELECT name FROM sys.databases'
179
try {
180
foreach ($r in $names.Rows) {
@@ -215,7 +210,7 @@ function Assert-DestinationDiskSpace($Plan) {
210
$required[$drive] += [long]$move.Bytes
211
}
212
foreach ($drive in $required.Keys) {
218
- $info = New-Object System.IO.DriveInfo($drive)
213
+ $info = [System.IO.DriveInfo]::new($drive)
214
if ($info.DriveType -ne [System.IO.DriveType]::Fixed -or
215
-not $info.IsReady -or
216
$info.AvailableFreeSpace -lt ($required[$drive] + 2GB)) {