feat(media): Make variant generation atomic with database
Per v1.5.0 Phase 4: - Generate variants to temp directory first - Perform database inserts in transaction - Move files to final location before commit - Clean up temp files on any failure - Add startup recovery for orphaned temp files - All media operations now fully atomic Changes: - Modified generate_all_variants() to return file moves - Modified save_media() to handle full atomic operation - Add cleanup_orphaned_temp_files() for startup recovery - Added 4 new tests for atomic behavior - Fixed HEIC variant format detection - Updated variant failure test for atomic behavior Fixes: - No orphaned files on database failures - No orphaned DB records on file failures - Startup recovery detects and cleans orphans 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -128,9 +128,12 @@ def create_app(config=None):
|
||||
configure_logging(app)
|
||||
|
||||
# Clean up old debug files (v1.5.0 Phase 2)
|
||||
from starpunk.media import cleanup_old_debug_files
|
||||
from starpunk.media import cleanup_old_debug_files, cleanup_orphaned_temp_files
|
||||
cleanup_old_debug_files(app)
|
||||
|
||||
# Clean up orphaned temp files (v1.5.0 Phase 4)
|
||||
cleanup_orphaned_temp_files(app)
|
||||
|
||||
# Initialize database schema
|
||||
from starpunk.database import init_db, init_pool
|
||||
|
||||
|
||||
Reference in New Issue
Block a user