1d94398e2d
Test and Lint / backend-test (push) Successful in 1m8s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m23s
Version and Release / version-bump (push) Successful in 32s
Version and Release / trigger-drone (push) Successful in 3s
- Fix archive deletion to also clean up associated thumbnails - Add cleanup-thumbnails.js script to remove temporary and orphaned thumbnails - Add diagnose-thumbnails.js script to troubleshoot thumbnail serving issues - Update README with documentation for new scripts This prevents thumbnail accumulation when events are deleted and helps diagnose why thumbnails might not be showing despite existing on disk. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
103 lines
2.4 KiB
Markdown
103 lines
2.4 KiB
Markdown
# Storage Management Scripts
|
|
|
|
## check-storage.js
|
|
|
|
Checks the storage directory structure and verifies that photo files exist.
|
|
|
|
### Usage:
|
|
```bash
|
|
# Check overall storage structure
|
|
node scripts/check-storage.js
|
|
|
|
# Check specific event
|
|
node scripts/check-storage.js wedding-test-gallery-2025-07-14-1
|
|
```
|
|
|
|
### What it checks:
|
|
- Storage directory structure and permissions
|
|
- Event directories
|
|
- Photo files existence
|
|
- Thumbnail files existence
|
|
- Database vs filesystem consistency
|
|
|
|
## regenerate-thumbnails.js
|
|
|
|
Regenerates missing thumbnails for photos in the database.
|
|
|
|
### Usage:
|
|
```bash
|
|
# Regenerate all missing thumbnails
|
|
node scripts/regenerate-thumbnails.js
|
|
|
|
# Regenerate thumbnails for specific event (by ID)
|
|
node scripts/regenerate-thumbnails.js 2
|
|
```
|
|
|
|
### What it does:
|
|
- Scans photos in database
|
|
- Checks if thumbnails exist
|
|
- Generates missing thumbnails using Sharp
|
|
- Updates database with thumbnail paths
|
|
- Reports success/error statistics
|
|
|
|
### Prerequisites:
|
|
- Node.js environment
|
|
- Database access
|
|
- Write permissions to storage directory
|
|
- Sharp library installed
|
|
|
|
## Production Usage
|
|
|
|
On your production server:
|
|
|
|
1. First, check the storage structure:
|
|
```bash
|
|
cd /path/to/picpeak/backend
|
|
NODE_ENV=production node scripts/check-storage.js wedding-test-gallery-2025-07-14-1
|
|
```
|
|
|
|
2. If thumbnails are missing, regenerate them:
|
|
```bash
|
|
NODE_ENV=production node scripts/regenerate-thumbnails.js 2
|
|
```
|
|
|
|
Note: Replace `2` with the actual event ID from your database.
|
|
|
|
## cleanup-thumbnails.js
|
|
|
|
Cleans up temporary and orphaned thumbnail files.
|
|
|
|
### Usage:
|
|
```bash
|
|
# Dry run - see what would be deleted
|
|
node scripts/cleanup-thumbnails.js --dry-run
|
|
|
|
# Actually delete orphaned thumbnails
|
|
node scripts/cleanup-thumbnails.js
|
|
```
|
|
|
|
### What it does:
|
|
- Identifies temporary thumbnails (thumb_temp_*)
|
|
- Finds orphaned thumbnails not linked to any photo
|
|
- Removes unnecessary files to free up space
|
|
- Reports statistics on cleanup
|
|
|
|
## diagnose-thumbnails.js
|
|
|
|
Diagnoses why thumbnails might not be showing for a specific event.
|
|
|
|
### Usage:
|
|
```bash
|
|
node scripts/diagnose-thumbnails.js 2
|
|
```
|
|
|
|
### What it checks:
|
|
- Thumbnail paths in database vs filesystem
|
|
- Path format inconsistencies
|
|
- Missing thumbnail files
|
|
- Provides SQL to fix path issues
|
|
|
|
### Common Issues:
|
|
1. **Path mismatch**: Database has wrong thumbnail path format
|
|
2. **Missing files**: Thumbnails were never generated
|
|
3. **Permission issues**: Web server can't read thumbnail files |