fix: сбрасывать stale pricelist "failed" когда NeedSync подтверждает актуальность
После сетевого сбоя во время синка прайслистов last_pricelist_status мог оставаться "failed" навсегда, даже если все прайслисты реально скачались и NeedSync() возвращает false (всё актуально). В SyncPricelistsIfNeeded: если NeedSync() == false и статус "failed" — сбрасываем в success и обновляем last_sync_time, чтобы UI убрал "Не докачано". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -894,6 +894,16 @@ func (s *Service) SyncPricelistsIfNeeded() error {
|
||||
|
||||
if !needSync {
|
||||
slog.Debug("pricelists are up to date, no sync needed")
|
||||
// Clear stale "failed" status: if NeedSync confirmed all active server pricelists
|
||||
// are present locally, any lingering failure flag is outdated.
|
||||
if strings.EqualFold(s.localDB.GetLastPricelistSyncStatus(), "failed") {
|
||||
now := time.Now()
|
||||
if err := s.localDB.SetPricelistSyncResult("success", "", now); err != nil {
|
||||
slog.Warn("failed to clear stale pricelist sync failure flag", "error", err)
|
||||
} else {
|
||||
s.localDB.SetLastSyncTime(now)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user