fix(scan): 扫描进行中拒绝重新扫描,避免破坏并发扫描

POST /api/scan 在 scanState.scanning 时直接返回 SCANNING,不再调用 invalidateScan 清空 pkgCache,防止进行中的扫描读到被清空的增量缓存导致数据不一致。前端收到 SCANNING 后转为轮询当前扫描进度,体验与正常扫描一致。
This commit is contained in:
yinjun.chen1
2026-09-22 09:31:38 +08:00
parent 552eb0df3f
commit ce81a59e84
2 changed files with 13 additions and 2 deletions
+8 -1
View File
@@ -162,7 +162,14 @@ async function scanNow() {
state.loading = true
try {
const res = await api.scanNow()
if (!res.ok) return res
if (!res.ok) {
// 扫描进行中:转为轮询当前扫描进度,扫完再拉取数据
if (res.code === 'SCANNING') {
await pollScanProgress()
await refreshPackages()
}
return res
}
await doRefresh()
return res
} finally {