fix(scan): 扫描进行中拒绝重新扫描,避免破坏并发扫描
POST /api/scan 在 scanState.scanning 时直接返回 SCANNING,不再调用 invalidateScan 清空 pkgCache,防止进行中的扫描读到被清空的增量缓存导致数据不一致。前端收到 SCANNING 后转为轮询当前扫描进度,体验与正常扫描一致。
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user