-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclean-test-temp.ps1
More file actions
65 lines (59 loc) · 1.81 KB
/
clean-test-temp.ps1
File metadata and controls
65 lines (59 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Ripulisce le cartelle temporanee create dai test BLite in $env:TEMP
# Sicuro: rimuove solo cartelle con prefissi noti + GUID nel nome
$tmp = $env:TEMP
$prefixes = @(
'blite_e2e_',
'blite_sm_',
'blite_mig_',
'blite_multifile_',
'blite_adv_',
'blite_eng_',
'blite_mf_',
'blite_bc_',
'blite_idx_',
'blite_chk_',
'blite_cdc_',
'blite_kv_',
'blite_ts_',
'blite_sp_',
'blite_vect_',
'blite_wtr_',
'blite_perf_',
'blite_sch_',
'blql_cov_',
'blql_',
'idx_linq_',
'test_crosspath_',
'linq_tests_'
)
$guidPattern = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
$removed = 0
$errors = 0
$bytes = 0L
foreach ($prefix in $prefixes) {
$dirs = Get-ChildItem -Path $tmp -Directory -Filter "${prefix}*" -ErrorAction SilentlyContinue |
Where-Object { $_.Name -match $guidPattern }
foreach ($dir in $dirs) {
try {
$sz = (Get-ChildItem $dir.FullName -Recurse -File -ErrorAction SilentlyContinue |
Measure-Object -Property Length -Sum).Sum
$bytes += $sz
[System.IO.Directory]::Delete($dir.FullName, $true)
$removed++
} catch {
Write-Warning "Impossibile eliminare: $($dir.FullName) - $_"
$errors++
}
}
}
$mb = [math]::Round($bytes / 1MB, 1)
Write-Host ""
Write-Host "============================================"
Write-Host " BLite Temp Cleanup - completato"
Write-Host "============================================"
Write-Host " Cartelle rimosse : $removed"
Write-Host " Spazio liberato : $mb MB"
if ($errors -gt 0) {
Write-Host " Errori : $errors (controlla i warning sopra)"
}
Write-Host "============================================"