lint: replace no-op flake8 script with gating ruff check, fix findings
CI / skip-ci-check (push) Successful in 18s
CI / python-lint (push) Failing after 19s
CI / docker-ci (push) Successful in 21s
CI / secret-scan (push) Successful in 30s
CI / skip-ci-check (pull_request) Successful in 27s
CI / python-lint (pull_request) Failing after 21s
CI / docker-ci (pull_request) Successful in 22s
CI / admin-unit (push) Successful in 44s
CI / secret-scan (pull_request) Successful in 45s
CI / admin-unit (pull_request) Successful in 55s
CI / viewer-unit (push) Successful in 1m54s
CI / viewer-unit (pull_request) Successful in 1m45s
CI / e2e (push) Failing after 6m5s
CI / e2e (pull_request) Successful in 6m43s
CI / skip-ci-check (push) Successful in 18s
CI / python-lint (push) Failing after 19s
CI / docker-ci (push) Successful in 21s
CI / secret-scan (push) Successful in 30s
CI / skip-ci-check (pull_request) Successful in 27s
CI / python-lint (pull_request) Failing after 21s
CI / docker-ci (pull_request) Successful in 22s
CI / admin-unit (push) Successful in 44s
CI / secret-scan (pull_request) Successful in 45s
CI / admin-unit (pull_request) Successful in 55s
CI / viewer-unit (push) Successful in 1m54s
CI / viewer-unit (pull_request) Successful in 1m45s
CI / e2e (push) Failing after 6m5s
CI / e2e (pull_request) Successful in 6m43s
This commit is contained in:
+26
-25
@@ -3,34 +3,29 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import List, Optional
|
||||
from typing import Annotated, List, Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, File, HTTPException, Query, Request, UploadFile, status, Request
|
||||
from fastapi.responses import JSONResponse, FileResponse, Response
|
||||
from typing import Annotated
|
||||
from rq import Queue
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, Request, status
|
||||
from fastapi.responses import Response
|
||||
from redis import Redis
|
||||
from rq import Queue
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from backend.db.session import get_db
|
||||
from backend.api.auth import get_current_user
|
||||
from backend.api.users import get_current_admin_user
|
||||
|
||||
# Redis connection for RQ
|
||||
redis_conn = Redis(host="localhost", port=6379, db=0, decode_responses=False)
|
||||
queue = Queue(connection=redis_conn)
|
||||
from backend.db.session import get_db
|
||||
from backend.schemas.photos import (
|
||||
PhotoImportRequest,
|
||||
PhotoImportResponse,
|
||||
PhotoResponse,
|
||||
BrowseDirectoryResponse,
|
||||
BulkAddFavoritesRequest,
|
||||
BulkAddFavoritesResponse,
|
||||
BulkDeletePhotosRequest,
|
||||
BulkDeletePhotosResponse,
|
||||
BulkRemoveFavoritesRequest,
|
||||
BulkRemoveFavoritesResponse,
|
||||
BrowseDirectoryResponse,
|
||||
DirectoryItem,
|
||||
PhotoImportRequest,
|
||||
PhotoImportResponse,
|
||||
PhotoResponse,
|
||||
)
|
||||
from backend.schemas.search import (
|
||||
PhotoSearchResult,
|
||||
@@ -52,6 +47,11 @@ from backend.services.search_service import (
|
||||
search_photos_by_name,
|
||||
search_photos_by_tags,
|
||||
)
|
||||
|
||||
# Redis connection for RQ
|
||||
redis_conn = Redis(host="localhost", port=6379, db=0, decode_responses=False)
|
||||
queue = Queue(connection=redis_conn)
|
||||
|
||||
# Note: Function passed as string path to avoid RQ serialization issues
|
||||
|
||||
router = APIRouter(prefix="/photos", tags=["photos"])
|
||||
@@ -415,9 +415,8 @@ async def upload_photos(
|
||||
For large batches, prefer the /import endpoint with folder_path.
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
from datetime import date, datetime
|
||||
from pathlib import Path
|
||||
from datetime import datetime, date
|
||||
|
||||
from backend.settings import PHOTO_STORAGE_DIR
|
||||
|
||||
@@ -466,7 +465,7 @@ async def upload_photos(
|
||||
if hasattr(request, '_form'):
|
||||
form = await request.form()
|
||||
files = form.getlist('files')
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if not files:
|
||||
@@ -581,7 +580,6 @@ def browse_directory(
|
||||
HTTPException: If path doesn't exist, is not a directory, or access is denied
|
||||
"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
try:
|
||||
# Convert to absolute path
|
||||
@@ -678,7 +676,6 @@ def browse_folder() -> dict:
|
||||
dict with 'path' (str) and 'success' (bool) keys
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
import tkinter as tk
|
||||
@@ -801,11 +798,13 @@ def get_photo_image(
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""Serve photo image or video file for display (not download)."""
|
||||
import os
|
||||
import mimetypes
|
||||
from backend.db.models import Photo
|
||||
import os
|
||||
|
||||
from starlette.responses import FileResponse
|
||||
|
||||
from backend.db.models import Photo
|
||||
|
||||
photo = db.query(Photo).filter(Photo.id == photo_id).first()
|
||||
if not photo:
|
||||
raise HTTPException(
|
||||
@@ -879,7 +878,7 @@ def get_photo_image(
|
||||
},
|
||||
media_type=media_type,
|
||||
)
|
||||
except (ValueError, IndexError) as e:
|
||||
except (ValueError, IndexError):
|
||||
# If range parsing fails, fall through to serve full file
|
||||
pass
|
||||
|
||||
@@ -1110,9 +1109,10 @@ def bulk_delete_photos(
|
||||
If a photo's file is in the uploads folder, it will also be deleted from the filesystem
|
||||
to prevent duplicate uploads.
|
||||
"""
|
||||
import os
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from backend.db.models import Photo, PhotoTagLinkage
|
||||
from backend.settings import PHOTO_STORAGE_DIR
|
||||
|
||||
@@ -1198,8 +1198,9 @@ def open_photo_folder(photo_id: int, db: Session = Depends(get_db)) -> dict:
|
||||
- Linux: tries file manager-specific commands (nautilus, dolphin, etc.) or opens folder
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from backend.db.models import Photo
|
||||
|
||||
photo = db.query(Photo).filter(Photo.id == photo_id).first()
|
||||
@@ -1238,7 +1239,7 @@ def open_photo_folder(photo_id: int, db: Session = Depends(get_db)) -> dict:
|
||||
except ImportError:
|
||||
# showinfm not installed, fall back to manual commands
|
||||
pass
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
# showinfm failed, fall back to manual commands
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user