From 246ddc716046ec5bc3e80d92f154cc4d9aca806d Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Tue, 2 Sep 2025 14:17:40 +0000 Subject: [PATCH] Update video information and refresh cached content Update video record in the database with new information and a timestamp. If the database update is successful, invalidate the cache to ensure the latest video data is loaded. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1/n7jzC7R --- server/storage.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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(