Fix storage path issues and React error #130
Backend fixes: - Add STORAGE_PATH environment variable support - Fix absolute path references in all backend services - Update Docker configuration with correct storage path Frontend fixes: - Remove individual ErrorBoundary wrappers to fix React error #130 - Remove unused ErrorBoundary import - Simplify route structure to prevent component mounting issues This resolves: - 500 errors when creating events due to storage permission issues - React error #130 that occurred during event creation - Consistent storage path handling across all services 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,17 +4,18 @@ const path = require('path');
|
||||
const { db } = require('../database/db');
|
||||
const logger = require('../utils/logger');
|
||||
|
||||
const ACTIVE_PATH = path.join(__dirname, '../../../storage/events/active');
|
||||
const ARCHIVE_PATH = path.join(__dirname, '../../../storage/events/archived');
|
||||
const getStoragePath = () => process.env.STORAGE_PATH || path.join(__dirname, '../../../storage');
|
||||
const ACTIVE_PATH = () => path.join(getStoragePath(), 'events/active');
|
||||
const ARCHIVE_PATH = () => path.join(getStoragePath(), 'events/archived');
|
||||
|
||||
async function archiveEvent(event) {
|
||||
try {
|
||||
const eventPath = path.join(ACTIVE_PATH, event.slug);
|
||||
const eventPath = path.join(ACTIVE_PATH(), event.slug);
|
||||
const archiveName = `${event.slug}.zip`;
|
||||
const archivePath = path.join(ARCHIVE_PATH, archiveName);
|
||||
const archivePath = path.join(ARCHIVE_PATH(), archiveName);
|
||||
|
||||
// Ensure archive directory exists
|
||||
await fs.mkdir(ARCHIVE_PATH, { recursive: true });
|
||||
await fs.mkdir(ARCHIVE_PATH(), { recursive: true });
|
||||
|
||||
// Create archive
|
||||
const output = require('fs').createWriteStream(archivePath);
|
||||
@@ -32,7 +33,7 @@ async function archiveEvent(event) {
|
||||
// Update database
|
||||
await db('events').where('id', event.id).update({
|
||||
is_archived: true,
|
||||
archive_path: path.relative(path.join(__dirname, '../../../storage'), archivePath),
|
||||
archive_path: path.relative(getStoragePath(), archivePath),
|
||||
archived_at: new Date()
|
||||
});
|
||||
|
||||
@@ -43,7 +44,7 @@ async function archiveEvent(event) {
|
||||
const photos = await db('photos').where('event_id', event.id);
|
||||
for (const photo of photos) {
|
||||
if (photo.thumbnail_path) {
|
||||
const thumbPath = path.join(__dirname, '../../../storage', photo.thumbnail_path);
|
||||
const thumbPath = path.join(getStoragePath(), photo.thumbnail_path);
|
||||
await fs.unlink(thumbPath).catch(() => {}); // Ignore if already deleted
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user