Skip to content

Commit 3c57a81

Browse files
committed
Ensure we don’t start another sync on reentry to POS
1 parent 699bdf5 commit 3c57a81

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Modules/Sources/Yosemite/Tools/POS/POSCatalogSyncCoordinator.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,12 @@ public actor POSCatalogSyncCoordinator: POSCatalogSyncCoordinatorProtocol {
9494
throw POSCatalogSyncError.shouldNotSync
9595
}
9696

97-
if case .syncStarted = fullSyncStateModel.state[siteID] {
97+
switch fullSyncStateModel.state[siteID] {
98+
case .syncStarted, .initialSyncStarted:
9899
DDLogInfo("⚠️ POSCatalogSyncCoordinator: Sync already in progress for site \(siteID)")
99100
throw POSCatalogSyncError.syncAlreadyInProgress(siteID: siteID)
101+
default:
102+
break
100103
}
101104

102105
let isFirstSync = await lastFullSyncDate(for: siteID) == nil

Modules/Tests/YosemiteTests/Tools/POS/POSCatalogSyncCoordinatorTests.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ struct POSCatalogSyncCoordinatorTests {
204204
}
205205

206206
let currentState = await sut.loadLastFullSyncState(for: sampleSiteID)
207-
let isSyncStarted: Bool = if case .syncStarted = currentState { true } else { false }
207+
let isSyncStarted: Bool = switch currentState {
208+
case .syncStarted, .initialSyncStarted: true
209+
default: false
210+
}
208211
#expect(isSyncStarted)
209212

210213
// Cleanup - resume the first sync and wait for it to complete

0 commit comments

Comments
 (0)