feat: 备份恢复 / 图片清理 / 单位恢复 / 审计过滤 / 模板引擎 M1 + 两个导入缺陷修复
用户点名的三件事(模板功能、删死代码、剩余缺口)这一批全部落地,另修掉两个刚暴露的导入缺陷:
**新增能力**
- 备份恢复:`POST /api/backup/restore`(admin)。先把校验做在拍快照之前(只读打开 + integrity_check +
关键表校验 + 异类库标志表互斥),再用 VACUUM INTO 拍「恢复前安全副本」,然后关连接、整文件替换、
触发优雅重启;`-wal` 还在时直接拒绝(宁可失败也不让旧库 WAL 套到新库上);恢复后审计直写"恢复之后
还在的那份库"(不走通用 Auditor,否则记录只会落在被替换掉的旧文件上)。顺带修掉:裸服务端连续恢复
第二次会在拍副本处崩出一句看不懂的 500,现在回 503「上次恢复后尚未重启,请先重启服务端」。
- 安全副本保留策略:每类库保留最近 5 份,独立于 .db 的 20 份滚动清理。
- 图片管理:`DELETE /api/uploads/{name}`(被引用 409 并列出引用点)、`GET /api/uploads/orphans`、
`POST /api/uploads/orphans/delete`(只删列出的孤儿,宁漏勿误),全部 admin(与字体删除同档);
`deploy/backup.bat` 补上 uploads/ 归档(logs 不归档:可再生的诊断且会无上限增长)。
- 已彻底删除单位的恢复:`POST /api/teams/{id}/restore`(与 hideTeam 同档)。幂等;恢复不会把「停用」
变成「启用」;真机确认恢复前后榜单逐字节一致、change_log 最大值不变(数据一行没动,不需要重算)。
界面加「显示已彻底删除的单位」(仅 admin)与恢复按钮;非 admin 的删除确认框里写明"本账号无法自行恢复"。
- 审计日志按 `action` 过滤(子串模糊,输入里的 %/_/\ 转义成字面量)。
- 删除死表 recent_projects(新增 system 迁移 0006,未动已应用的迁移)。
- points_override 不再"设了没效果":写入侧 400 + 引擎侧守卫,提示改用「积分调整」。
- 联队份额空壳清理(UnionAttribution/UnionSplit/Entry.TeamShares/resolvedShares 等;TeamShare 类型保留,
因为 export/realtime/奖牌流水三处在生产路径上构造它)。
- 自定义大屏模板 M1:插值引擎(parseTemplate/renderTemplate),任何情况都不抛异常、未定义→空串+警告、
警告按 (code,path) 合并计数、无 eval/innerHTML,57 个新用例。
**两个真缺陷(前两个已随 0.1.6 出包)**
- 基础数据包导入「排序」列口径不一致:小项/组别留空保持原值,单位/大项留空被写成 0(plan 没从库里
现值起手)→ 四张表统一为「留空保持原值」。
- 同类第二处:布尔列「整列被删掉」被当成"取默认值",会把库里所有停用的单位/大项静默改回启用 →
改为「缺列 = 不动」(写侧与解析侧都收口,补了"缺列保持/空格子=是/显式否=停用"三组对照用例)。
**删死代码**
- createEntry / updateEntry / deleteEntry / entryEventID / checkCategoryInEvent / getEntry /
normalizeEntryStatus / ExportBaseDataXLSX(全仓 grep 零引用)。⚠️ 随之记入文档:「组别必须属于该小项」
这道校验现在只由导入路径"按小项+组别名解析"天然保证,将来若新增从请求体接收 categoryId 的接口,
必须自己补校验(库层没有复合外键)。
**文档**
- devdocs 全面同步(01/02/03/04/05/06/07/09/11/12/13/README;含身份口径、延迟结算、大屏单栏新版式、
新增路由与设置键、R18/R19 风险);docs 复核 + 第二轮(身份口径三个易写反的分支、图片删除、备份覆盖、
审计过滤、单位恢复、去掉硬编码版本号、上线检查清单 +5 项);debug/使用说明 6 份逐份 diff 一致。
测试:服务端 13 包(连跑两遍)、前端 406 例、Console 28 例 + 18 文件语法检查 —— 全绿。
版本号 dev_0.1.6 → dev_0.1.7。
This commit is contained in:
1 parent
631c8dd8e1
commit
53a0cb225c
61 files changed
+6386
-699
No files matched your search
+48
-4
@@ -10,9 +10,18 @@ REM The data dir is the one the Console uses, i.e. %LOCALAPPDATA%\ScoreboardCon
|
||||
REM (falling back to <root>\data when that does not exist yet). It lives outside
|
||||
REM the install dir on purpose: reinstalling over an existing install wipes the
|
||||
REM install dir, so data must not be kept there.
|
||||
REM NOTE: only .db snapshots are taken. Background images / emblems under
|
||||
REM <data dir>\event_projs\<project>\uploads\ are NOT included; copy that
|
||||
REM directory separately if you need them on the archive.
|
||||
REM NOTE: the .db snapshots below are not the whole event. Uploaded image assets
|
||||
REM (event logo, display background/logo, team logos) and uploaded fonts
|
||||
REM live as files under <data dir>\event_projs\<project>\uploads\ and are
|
||||
REM referenced from the DB by path, so this script also zips each
|
||||
REM project's uploads\ into <data dir>\backups\ next to its snapshots.
|
||||
REM Logs under <data dir>\logs\ are NOT archived: the server rotates them
|
||||
REM (log.* in config.yaml), they can grow without bound, and they are
|
||||
REM diagnostics rather than data -- copy that directory by hand when a
|
||||
REM post-mortem needs it.
|
||||
REM The uploads zips are NOT pruned by the server (its 20-file rotation
|
||||
REM only counts .db files), so delete old *-uploads-*.zip by hand when
|
||||
REM they pile up -- keep at least the newest one per project.
|
||||
REM
|
||||
REM Usage: deploy\backup.bat manual backup (reason=manual)
|
||||
REM deploy\backup.bat publish pre-publish backup (reason=publish)
|
||||
@@ -92,13 +101,48 @@ if not defined FOUND (
|
||||
if errorlevel 1 (set /a FAIL+=1) else (set /a OK+=1)
|
||||
)
|
||||
|
||||
REM Archive each project's uploads\ (images + uploaded fonts under
|
||||
REM uploads\fonts\). One timestamp is reused for every project so the snapshots
|
||||
REM of a single run sort together.
|
||||
set /a ASSETS=0
|
||||
set /a ASSETS_FAIL=0
|
||||
for /f %%T in ('powershell -NoProfile -NonInteractive -Command "Get-Date -Format yyyyMMdd-HHmmss"') do set "STAMP=%%T"
|
||||
if not defined STAMP set "STAMP=unknown"
|
||||
for /d %%D in ("%DATA%\event_projs\*") do call :archive_uploads "%%~nxD" "%%~fD"
|
||||
|
||||
echo.
|
||||
echo === backup done: ok=!OK! fail=!FAIL! ===
|
||||
echo === backup done: ok=!OK! fail=!FAIL! assets=!ASSETS! assets_fail=!ASSETS_FAIL! ===
|
||||
dir /b "%DATA%\backups\*.db" 2>nul
|
||||
dir /b "%DATA%\backups\*-uploads-*.zip" 2>nul
|
||||
|
||||
if !FAIL! GTR 0 (
|
||||
endlocal
|
||||
exit /b 1
|
||||
)
|
||||
if !ASSETS_FAIL! GTR 0 (
|
||||
endlocal
|
||||
exit /b 1
|
||||
)
|
||||
endlocal
|
||||
exit /b 0
|
||||
|
||||
REM ==== subroutines ===========================================================
|
||||
REM %1 = project name, %2 = project dir. The archive keeps the top-level
|
||||
REM "uploads" folder name, so unzipping into a project dir puts the files back
|
||||
REM exactly where the server reads them from.
|
||||
:archive_uploads
|
||||
set "HASFILES="
|
||||
for /f "delims=" %%F in ('dir /b /s /a-d "%~2\uploads" 2^>nul') do set "HASFILES=1"
|
||||
if not defined HASFILES (
|
||||
echo no assets %~1\uploads (empty, skipped)
|
||||
exit /b 0
|
||||
)
|
||||
echo archive assets %~1\uploads
|
||||
powershell -NoProfile -NonInteractive -Command "$ErrorActionPreference='Stop'; Compress-Archive -Path '%~2\uploads' -DestinationPath '%DATA%\backups\%~1-uploads-%STAMP%.zip' -Force"
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] archiving %~1\uploads failed
|
||||
set /a ASSETS_FAIL+=1
|
||||
) else (
|
||||
set /a ASSETS+=1
|
||||
)
|
||||
exit /b 0
|
||||
Reference in new issue
Block a user