Fix critical issues: gallery authentication and photo duplication
- Fix gallery-specific authentication for images - Update AuthenticatedImage component to use gallery-specific tokens - Add isGallery prop to distinguish between admin and gallery contexts - Update PhotoGrid and PhotoLightbox to pass isGallery prop - Fix photo duplication issue in fileWatcher service - Add check to prevent duplicate photo entries when backend restarts - File watcher now verifies if photo exists before inserting - Cleaned up 176 duplicate photos from database These fixes resolve: 1. Gallery images not loading due to auth token errors 2. Photo count increasing without new uploads due to duplicates 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -63,17 +63,26 @@ async function processNewPhoto(filePath) {
|
||||
// Calculate relative thumbnail path
|
||||
const relativeThumbPath = thumbnailPath; // thumbnailPath is already relative to storage root
|
||||
|
||||
// Add to database
|
||||
await db('photos').insert({
|
||||
event_id: event.id,
|
||||
filename: path.basename(filePath),
|
||||
path: relativePath,
|
||||
thumbnail_path: relativeThumbPath,
|
||||
type: photoType,
|
||||
size_bytes: stats.size
|
||||
});
|
||||
// Check if photo already exists
|
||||
const existingPhoto = await db('photos')
|
||||
.where({ event_id: event.id, filename: path.basename(filePath) })
|
||||
.first();
|
||||
|
||||
logger.info(`Added new photo: ${relativePath}`);
|
||||
if (!existingPhoto) {
|
||||
// Add to database
|
||||
await db('photos').insert({
|
||||
event_id: event.id,
|
||||
filename: path.basename(filePath),
|
||||
path: relativePath,
|
||||
thumbnail_path: relativeThumbPath,
|
||||
type: photoType,
|
||||
size_bytes: stats.size
|
||||
});
|
||||
|
||||
logger.info(`Added new photo: ${relativePath}`);
|
||||
} else {
|
||||
logger.debug(`Photo already exists: ${relativePath}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function removePhoto(filePath) {
|
||||
|
||||
Reference in New Issue
Block a user