mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-07 08:23:12 -05:00
fix: strict optional errors (#1759)
* fix strict optional errors * fix typing in repository * fix backup db files location * update workspace settings
This commit is contained in:
@@ -19,6 +19,10 @@ class UserFavoritesController(BaseUserController):
|
||||
def add_favorite(self, id: UUID4, slug: str):
|
||||
"""Adds a Recipe to the users favorites"""
|
||||
assert_user_change_allowed(id, self.user)
|
||||
|
||||
if not self.user.favorite_recipes:
|
||||
self.user.favorite_recipes = []
|
||||
|
||||
self.user.favorite_recipes.append(slug)
|
||||
self.repos.users.update(self.user.id, self.user)
|
||||
|
||||
@@ -26,6 +30,10 @@ class UserFavoritesController(BaseUserController):
|
||||
def remove_favorite(self, id: UUID4, slug: str):
|
||||
"""Adds a Recipe to the users favorites"""
|
||||
assert_user_change_allowed(id, self.user)
|
||||
|
||||
if not self.user.favorite_recipes:
|
||||
self.user.favorite_recipes = []
|
||||
|
||||
self.user.favorite_recipes = [x for x in self.user.favorite_recipes if x != slug]
|
||||
self.repos.users.update(self.user.id, self.user)
|
||||
return
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from starlette.responses import FileResponse
|
||||
@@ -10,7 +9,7 @@ router = APIRouter(prefix="/api/utils", tags=["Utils"], include_in_schema=True)
|
||||
|
||||
|
||||
@router.get("/download")
|
||||
async def download_file(file_path: Optional[Path] = Depends(validate_file_token)):
|
||||
async def download_file(file_path: Path = Depends(validate_file_token)):
|
||||
"""Uses a file token obtained by an active user to retrieve a file from the operating
|
||||
system."""
|
||||
if not file_path.is_file():
|
||||
|
||||
Reference in New Issue
Block a user