Skip to content

Fix stuck scan bug, reorganize repo, and clean up docs (v2.5.67)#38

Merged
ttlequals0 merged 3 commits intomainfrom
fix/stuck-scan-docs-and-repo-cleanup
Mar 6, 2026
Merged

Fix stuck scan bug, reorganize repo, and clean up docs (v2.5.67)#38
ttlequals0 merged 3 commits intomainfrom
fix/stuck-scan-docs-and-repo-cleanup

Conversation

@ttlequals0
Copy link
Owner

@ttlequals0 ttlequals0 commented Mar 5, 2026

Summary

  • Fix stuck scan bug: Crash recovery in scan_service.py now calls db.session.rollback() before recovery writes, preventing scans from getting permanently stuck after Celery task crashes (e.g., psycopg2.DatabaseError). Also improved stuck scan detection in scan_routes.py (time-based fallback when task state is unknown) and scheduler.py (verify Celery task state, not just time threshold).
  • Fix Phase 3 progress display: Scan-status API now reads real-time progress from Redis instead of only PostgreSQL. Added get_scan_progress_redis() for reading Redis progress, and _mark_scan_completed() to consolidate 7 duplicated scan completion SQL blocks into one method.
  • Fix ORM staleness in final sync: Added ui_session.refresh(scan_state) in _final_sync_redis_to_db() to prevent stale ORM values after raw SQL updates.
  • Code cleanup: Moved inline import to module level in tasks.py, removed trailing whitespace in scan_routes.py.
  • Reorganize repo: Moved 7 root-level Python modules (models.py, auth.py, config.py, media_checker.py, scheduler.py, celery_config.py, version.py) into the pixelprobe/ package. Root now only contains entry points (app.py, celery_worker.py) and build/config files. Updated 73+ import paths across 43+ files.
  • Repository cleanup: Deleted 18 legacy/unused files including database_migrations.py, init_db.py, operation_handlers.py, utils.py, entire migrations/ directory, broken shell scripts, obsolete patches, and outdated dev docs.
  • Documentation cleanup: Fixed port 5001->5000 across 4 docs, updated stale version refs (v2.4.48/v2.4.93), removed SQLite references (PostgreSQL-only since v2.2.0), rewrote PROJECT_STRUCTURE.md, fixed container name references, corrected API endpoint paths.
  • Cleared stuck scan 1432 on live server via API.

Test plan

  • Full test suite: 251 passed, 0 failed, 8 skipped
  • Fixed 2 test monkeypatch paths broken by module move
  • Added 12 new unit tests for get_scan_progress_redis(), _final_sync_redis_to_db(), and _mark_scan_completed()
  • Verified stuck scan 1432 cleared on live server
  • Verified no remaining old-style imports (from models import, etc.)
  • Docker build: ttlequals0/pixelprobe:2.5.67 pushed to Docker Hub

ttlequals0 and others added 3 commits March 5, 2026 18:10
Fix crash recovery session handling -- scans could get permanently stuck
after a Celery task crash because the DB session was in a rolled-back
state and recovery writes silently failed. Also improve stuck scan
detection when Celery task state is unknown.

Move all application modules into pixelprobe/ package so root only
contains entry points (app.py, celery_worker.py) and build/config files.
Update 73+ import paths across 43+ files. Delete legacy files, broken
scripts, and obsolete docs. Fix documentation inaccuracies (wrong ports,
stale version refs, SQLite references).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Read real-time scan progress from Redis in scan-status API endpoint
  (Redis is updated per-file by Celery workers; PostgreSQL lagged behind)
- Write files_processed/estimated_total in all scan completion SQL UPDATEs
- Add final Redis-to-DB sync in ui_progress_update_task before exit
- Extract _mark_scan_completed() helper replacing 7 duplicated SQL blocks
- Add get_scan_progress_redis() and _PROGRESS_KEY_PREFIX to progress_utils
- Move get_scan_progress_redis import to module level in scan_routes
- Update architecture docs to reflect Redis-first progress flow
- Fix README: WebSocket->polling, stale media_checker import path

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move inline import of get_scan_progress_redis to module level in tasks.py
- Add ui_session.refresh(scan_state) in _final_sync_redis_to_db to prevent
  stale ORM values after raw SQL updates from _mark_scan_completed
- Remove trailing whitespace in scan_routes.py
- Add 12 unit tests for get_scan_progress_redis, _final_sync_redis_to_db
  sync logic, and _mark_scan_completed SQL behavior

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ttlequals0 ttlequals0 merged commit 995e276 into main Mar 6, 2026
6 checks passed
@ttlequals0 ttlequals0 deleted the fix/stuck-scan-docs-and-repo-cleanup branch March 6, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant