User-facing labels and code now use "discard" (verb) and "Discarded"
(state/view label) instead of "trash" / "Trashed". The DB column names
stay (is_trashed / trashed_at) so no migration is required — only the
SQLAlchemy attribute names are renamed via Column('old_name', ...).
Backend
- Photo model: is_discarded / discarded_at attributes (DB columns
unchanged).
- PhotoBase / PhotoResponse / PhotoUpdate schemas use the new field
names.
- Photos list endpoint: is_discarded query param, filter logic.
- DELETE /photos/{id} now sets is_discarded; success message updated.
- Bulk action 'trash' renamed to 'discard'.
- backend/app/routers/trash.py renamed to discard.py with renamed
functions and route prefix /api/v1/discard.
- main.py imports and mounts the discard router.
- tasks/scan.py marks missing files as is_discarded.
Frontend
- Photo TS type: is_discarded.
- PhotoThumbnail: shows the trash-can icon when is_discarded.
- RightSidebar: button label "Discard"; mutation field name; local
variable rename.
- TopBar: discardPhotosMutation and "Discard" button; toast text
"Discarded".
- LeftSidebar: virtual node id 'discarded' / label "Discarded".
- FilterBar / filterStore / useFilterUrlSync: FlagFilter enum value
'trashed' → 'discarded'; backend param key is_discarded.
- KeyboardHints: X label "Discard".
- useKeyboardShortcuts: PhotoUpdate field rename, X handler.
- api.ts: /trash routes → /discard, trash export → discard,
bulkUpdate trash field → discard.
Out of scope (intentional): the docker-compose trash_data volume,
backend/Dockerfile mkdir /data/trash, config.py TrashSettings, and
the spec doc — all unused since soft-discard, and renaming them is
churn for no benefit.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
82 lines
2.4 KiB
Python
82 lines
2.4 KiB
Python
"""
|
|
Mulita - Photo Management Application
|
|
Main FastAPI application entry point
|
|
"""
|
|
from contextlib import asynccontextmanager
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.staticfiles import StaticFiles
|
|
import logging
|
|
import os
|
|
|
|
from app.config import settings
|
|
from app.database import init_db
|
|
from app.routers import photos, folders, heaps, tags, discard, library
|
|
from app.services.scanner import start_initial_scan
|
|
|
|
# Configure logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
"""Manage application lifecycle"""
|
|
logger.info("Starting Mulita application...")
|
|
|
|
# Initialize database
|
|
await init_db()
|
|
|
|
# Start initial scan if configured
|
|
if settings.scanner.initial_scan_on_start:
|
|
logger.info("Starting initial library scan...")
|
|
await start_initial_scan()
|
|
|
|
yield
|
|
|
|
logger.info("Shutting down Mulita application...")
|
|
|
|
# Create FastAPI app
|
|
app = FastAPI(
|
|
title="Mulita Photo Management API",
|
|
description="Self-hosted photo management application inspired by Lightroom",
|
|
version="1.0.0",
|
|
lifespan=lifespan
|
|
)
|
|
|
|
# Configure CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["http://localhost:3000", "http://localhost:5173"], # Frontend URLs
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Mount static files for serving thumbnails (with X-Accel-Redirect support)
|
|
if os.path.exists("/data/thumbs"):
|
|
app.mount("/thumbs", StaticFiles(directory="/data/thumbs"), name="thumbs")
|
|
|
|
# Include routers
|
|
app.include_router(photos.router, prefix="/api/v1/photos", tags=["photos"])
|
|
app.include_router(folders.router, prefix="/api/v1/folders", tags=["folders"])
|
|
app.include_router(heaps.router, prefix="/api/v1/heaps", tags=["heaps"])
|
|
app.include_router(tags.router, prefix="/api/v1/tags", tags=["tags"])
|
|
app.include_router(discard.router, prefix="/api/v1/discard", tags=["discard"])
|
|
app.include_router(library.router, prefix="/api/v1/library", tags=["library"])
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
"""Root endpoint"""
|
|
return {
|
|
"name": "Mulita Photo Management API",
|
|
"version": "1.0.0",
|
|
"status": "running"
|
|
}
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
"""Health check endpoint for Docker"""
|
|
return {"status": "healthy"} |