diff --git a/server/storage.ts b/server/storage.ts index 5ad0339..0efee18 100644 --- a/server/storage.ts +++ b/server/storage.ts @@ -850,12 +850,27 @@ class BunnyStorage implements IStorage { try { // Try to update in database first + let dbUpdateSuccessful = false; try { - await db.update(videos).set(updates as UpdateVideo).where(eq(videos.id, id)); + await db.update(videos).set({...updates, updatedAt: new Date()}).where(eq(videos.id, id)); + console.log(`Successfully updated video ${id} in database`); + dbUpdateSuccessful = true; } catch (dbError) { console.warn(`Database update failed for video ${id}, using cache:`, dbError); } + // If database update was successful, invalidate cache to refresh with updated data + if (dbUpdateSuccessful) { + try { + const { videoSyncService } = await import('./videoSync'); + console.log(`Invalidating cache for updated video ${id}...`); + await videoSyncService.initialize(); + console.log(`Cache invalidated after updating video ${id}`); + } catch (syncError) { + console.warn('Failed to invalidate cache after video update:', syncError); + } + } + // Update face detection data in cache if present const faceFields = ['faceCenterPosition', 'facesDetected', 'faceConfidence']; const faceData = Object.fromEntries(