Skip to content

fix: prevent splash screen after log rotation#64

Merged
K0lin merged 5 commits intomainfrom
dev
Feb 14, 2026
Merged

fix: prevent splash screen after log rotation#64
K0lin merged 5 commits intomainfrom
dev

Conversation

@K0lin
Copy link
Copy Markdown
Owner

@K0lin K0lin commented Feb 13, 2026

Problem

After log rotation, the splash screen would incorrectly appear even though the database already contained data. This happened because:

  1. Log rotation creates a new empty file → fileSize = 0
  2. Percentage calculation returned 0% (division by zero guard)
  3. Frontend saw 0% progress → showed splash screen
    Additionally, hasExistingData was only set when sources existed at startup, causing issues when sources were added later.

Fix #63

Solution

  • stats.go: Fix percentage calculation - return 100% when fileSize = 0 but LastPosition > 0 (data was processed before rotation)
  • http_request.go: Add HasExistingData() method with caching
  • coordinator.go: Move hasExistingData check to NewCoordinator() so it's always initialized before any processors are created
  • processor.go: Update isInitialLoad logic to consider hasExistingData

Changes

File Change
internal/database/repositories/stats.go Fix percentage for post-rotation files
internal/database/repositories/http_request.go Add HasExistingData() with caching
internal/ingestion/coordinator.go Initialize hasExistingData in constructor
internal/ingestion/processor.go Add hasExistingData parameter

Impact

  • Splash screen now only shows on fresh installations
  • No changes to initial load behavior for new deployments
  • Minimal, backward-compatible changes

Added HasExistingData method to check if the database contains data, optimizing performance by caching the result. Adjusted related fields and locking mechanisms for thread safety.
Changed processors from a slice to a map for O(1) lookup efficiency and added hasExistingData field to track existing data status.
Update initial load condition to check for existing data.
Refactor to set hasExistingData during initialization instead of in Start method.
@K0lin K0lin self-assigned this Feb 13, 2026
@K0lin K0lin linked an issue Feb 13, 2026 that may be closed by this pull request
@K0lin K0lin merged commit 2f8ca3d into main Feb 14, 2026
4 checks passed
@K0lin K0lin deleted the dev branch February 18, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] UI unavailable during long processing of Caddy logs

1 participant