feat(worker): 四类进度用 manifest 真实总量,未知保持 NULL
build / build (push) Successful in 1m11s

为什么:P02 要求分项计数/字节来自真实清单,不能永远 NULL 或写 0。
This commit is contained in:
姚章浩
2026-10-28 19:55:43 +08:00
parent f722ea8727
commit cef25d92a6
2 changed files with 49 additions and 4 deletions
+8
View File
@@ -13,6 +13,7 @@ import (
"knowledge-governance/internal/governance"
"knowledge-governance/internal/jobs"
"knowledge-governance/internal/libraryrelease"
"knowledge-governance/internal/librarysnapshot"
postgresstore "knowledge-governance/internal/platform/postgres"
)
@@ -37,6 +38,13 @@ func runLibraryRelease(ctx context.Context, store *postgresstore.Store, config a
now := time.Now().UTC()
_ = store.AdvanceLibraryJob(ctx, payload.LibraryJobID, governance.LibraryJobRunning, "prebackup", "", "", "", "", now)
recorder := libraryStageRecorder{store: store, jobID: payload.LibraryJobID, scope: payload.Scope}
// 四类进度的真实总量来自快照清单(manifest):读不到就保持 NULL,不写 0。
if archive, openErr := librarysnapshot.Open(config.LibraryArchiveRoot, 256*1024*1024); openErr == nil {
if manifest, loadErr := archive.Load(payload.TargetSnapshotID); loadErr == nil {
recorder.totals = stageSizesFrom(manifest)
}
archive.Close()
}
// 崩溃接管:作业里已经持久化过预备份快照,就直接复用它继续,
// 绝不重新备份——重新备份会把"半写状态"当成新基线,覆盖真正可回滚的那份。