Refactor: Replace Immich integration with local file storage and admin auth
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -13,10 +13,8 @@ from dotenv import load_dotenv
|
||||
@dataclass
|
||||
class Settings:
|
||||
"""App settings loaded from environment variables (.env)."""
|
||||
immich_base_url: str
|
||||
immich_api_key: str
|
||||
admin_password: str
|
||||
max_concurrent: int
|
||||
album_name: str = ""
|
||||
public_upload_page_enabled: bool = False
|
||||
public_base_url: str = ""
|
||||
state_db: str = ""
|
||||
@@ -25,16 +23,6 @@ class Settings:
|
||||
chunked_uploads_enabled: bool = False
|
||||
chunk_size_mb: int = 95
|
||||
|
||||
@property
|
||||
def normalized_base_url(self) -> str:
|
||||
"""Return the base URL without a trailing slash for clean joining and display."""
|
||||
return self.immich_base_url.rstrip("/")
|
||||
|
||||
@property
|
||||
def local_save_only(self) -> bool:
|
||||
"""True if configured to save locally instead of uploading to Immich."""
|
||||
return str(self.immich_base_url).lower() == "false"
|
||||
|
||||
def load_settings() -> Settings:
|
||||
"""Load settings from .env, applying defaults when absent."""
|
||||
# Load environment variables from .env once here so importers don’t have to
|
||||
@@ -42,9 +30,7 @@ def load_settings() -> Settings:
|
||||
load_dotenv()
|
||||
except Exception:
|
||||
pass
|
||||
base = os.getenv("IMMICH_BASE_URL", "http://127.0.0.1:2283/api")
|
||||
api_key = os.getenv("IMMICH_API_KEY", "")
|
||||
album_name = os.getenv("IMMICH_ALBUM_NAME", "")
|
||||
admin_password = os.getenv("ADMIN_PASSWORD", "admin") # Default for convenience, should be changed
|
||||
# Safe defaults: disable public uploader and invites unless explicitly enabled
|
||||
def as_bool(v: str, default: bool = False) -> bool:
|
||||
if v is None:
|
||||
@@ -64,10 +50,8 @@ def load_settings() -> Settings:
|
||||
except ValueError:
|
||||
chunk_size_mb = 95
|
||||
return Settings(
|
||||
immich_base_url=base,
|
||||
immich_api_key=api_key,
|
||||
admin_password=admin_password,
|
||||
max_concurrent=maxc,
|
||||
album_name=album_name,
|
||||
public_upload_page_enabled=public_upload,
|
||||
public_base_url=os.getenv("PUBLIC_BASE_URL", ""),
|
||||
state_db=state_db,
|
||||
|
||||
Reference in New Issue
Block a user