From 619e822d8568d79975da84baea0447b1f2ae2467 Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Fri, 22 May 2026 19:44:53 +0800 Subject: [PATCH] fix: clear stale nonCurrentRelease regardless of polled review state Previous fix only cleared stale APPROVED+nonCurrentRelease states when poll returned mappedState==APPROVED. If the store API returned UNDER_REVIEW (for the newly-submitted version) while the DB still held a stale APPROVED+nonCurrentRelease from the old online version, the stale state was never cleared. Add universal cleanup: before any mappedState branching, if onlineVersionCode < submittedCode and the DB entry has nonCurrentRelease/preExisting flags, immediately clear the store review state. Co-Authored-By: Claude Opus 4.7 --- .../service/StoreSubmissionService.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/update-service/src/main/java/com/xuqm/update/service/StoreSubmissionService.java b/update-service/src/main/java/com/xuqm/update/service/StoreSubmissionService.java index 321c7b9..f4967a7 100644 --- a/update-service/src/main/java/com/xuqm/update/service/StoreSubmissionService.java +++ b/update-service/src/main/java/com/xuqm/update/service/StoreSubmissionService.java @@ -840,6 +840,28 @@ public class StoreSubmissionService { boolean isUnderReview = "UNDER_REVIEW".equals(existingState); boolean isRejected = "REJECTED".equals(existingState); boolean isApproved = "APPROVED".equals(existingState); + + // Stale-state cleanup: previous buggy code wrote nonCurrentRelease/preExisting + // whenever an online version existed, regardless of whether it was newer or older. + // If the online version is OLDER than the submitted version, clear any stale marks + // so the user can submit this newer version. + if (!polled.getOnlineVersionCode().isBlank()) { + int cmp = compareVersionCodes(polled.getOnlineVersionCode(), String.valueOf(v.getVersionCode())); + if (cmp < 0 && entry instanceof Map m) { + Object nonCurrentRelease = m.get("nonCurrentRelease"); + Object preExisting = m.get("preExisting"); + if (Boolean.TRUE.equals(nonCurrentRelease) || Boolean.TRUE.equals(preExisting)) { + log.info("Manual refresh: {}/{} clearing stale nonCurrentRelease/preExisting — online {} < submitted {}", + v.getId(), storeType, polled.getOnlineVersionCode(), v.getVersionCode()); + storeService.clearStoreReview(v.getId(), storeType); + isApproved = false; + isUnderReview = false; + isRejected = false; + existingState = ""; + } + } + } + AppVersionEntity.StoreReviewState mappedState = mapToStoreReviewState(polled.getReviewState()); if (mappedState == AppVersionEntity.StoreReviewState.APPROVED) { if (polled.isCurrentSubmissionLive()) {