Files
HenryandClaude Code e497d36ba1 初始提交:浩瑞(HaoRui)头条自动化工程
- app/:Kotlin 全部源码、AndroidManifest 与资源
- docs/:技术文档、UI 原型、回归清单
- img/:文档引用的对照规格截图
- scripts/:环境加载与回归统计脚本
- 构建配置:Gradle 入口脚本与属性
- 新增 .gitignore:排除工具链、构建缓存、临时产物与本机配置

Co-Authored-By: Claude Code <[email protected]>
2026-11-06 17:26:51 +08:00

78 lines
2.6 KiB
PowerShell

# HaoRui - C-drive write checker
# Usage: .\scripts\check-c-drive.ps1 [-Baseline]
# Note: written in UTF-8 with BOM so PowerShell 5.1 parses Chinese correctly.
param([switch]$Baseline)
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
$snapPath = Join-Path $root '.tmp\c-drive-snapshot.txt'
# Hotspot dirs under C that our build might touch
$hotspots = @(
"$env:USERPROFILE\.gradle",
"$env:USERPROFILE\.android",
"$env:USERPROFILE\.m2",
"$env:USERPROFILE\.npm",
"$env:LOCALAPPDATA\Android",
"$env:LOCALAPPDATA\Temp",
"$env:TEMP"
)
function Get-Snapshot {
$rows = @()
foreach ($h in $hotspots) {
if (-not (Test-Path $h)) { $rows += "$h|0|0|-"; continue }
$files = Get-ChildItem -Path $h -Recurse -File -ErrorAction SilentlyContinue
$count = ($files | Measure-Object).Count
$sum = ($files | Measure-Object -Property Length -Sum).Sum
if ($null -eq $sum) { $sum = 0 }
$newest = ($files | Sort-Object LastWriteTime -Descending | Select-Object -First 1)
$ts = if ($newest) { $newest.LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss') } else { '-' }
$rows += "$h|$count|$sum|$ts"
}
return $rows
}
$snap = Get-Snapshot
if ($Baseline) {
$snap | Set-Content -Path $snapPath -Encoding utf8
Write-Host "[BASELINE SAVED] $snapPath" -ForegroundColor Green
foreach ($r in $snap) { Write-Host " $r" }
exit 0
}
if (-not (Test-Path $snapPath)) {
Write-Host "[MISSING BASELINE] run: .\scripts\check-c-drive.ps1 -Baseline" -ForegroundColor Yellow
Write-Host "Current hotspots:" -ForegroundColor Cyan
foreach ($r in $snap) { Write-Host " $r" }
exit 1
}
$base = Get-Content $snapPath -Encoding utf8
Write-Host "---- C-drive write check ----" -ForegroundColor Cyan
Write-Host ("{0,-34} {1,10} {2,14} {3,20} {4}" -f 'dir', 'files', 'bytes', 'newest', 'status')
Write-Host ("-" * 92)
$violations = 0
for ($i = 0; $i -lt $snap.Count; $i++) {
$b = $base[$i].Split('|')
$n = $snap[$i].Split('|')
$changed = ($b[1] -ne $n[1]) -or ($b[2] -ne $n[2])
if ($changed) { $violations++ }
$mark = if ($changed) { '[CHANGED]' } else { '[OK]' }
$leaf = Split-Path $n[0] -Leaf
Write-Host ("{0,-34} {1,10} {2,14} {3,20} {4}" -f $leaf, $n[1], $n[2], $n[3], $mark)
}
Write-Host ""
if ($violations -eq 0) {
Write-Host "[PASS] C-drive zero write" -ForegroundColor Green
exit 0
} else {
Write-Host "[WARN] $violations hotspot dir(s) changed" -ForegroundColor Yellow
Write-Host " If caused by build, verify env.ps1 was loaded first." -ForegroundColor Yellow
exit 1
}