From d372020bac4de275722568c8ace4f1621186b35f Mon Sep 17 00:00:00 2001 From: AaronBenDaniel <144371000+AaronBenDaniel@users.noreply.github.com> Date: Tue, 24 Jun 2025 15:26:53 -0400 Subject: [PATCH] fix: Change name of flag to enable PDF downloads --- Dockerfile | 4 ++-- src/api/src/main.py | 8 ++++---- src/frontend/src/routes/+page.svelte | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2aff431..d470f34 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,8 @@ RUN rm -rf build RUN npm install COPY src/frontend/. . -ARG feature_flag=false -ENV VITE_FEATURE_FLAG=$feature_flag +ARG pdfs=false +ENV VITE_ENABLE_PDFS=$pdfs RUN npm run build # Thanks https://stackoverflow.com/q/76988450 diff --git a/src/api/src/main.py b/src/api/src/main.py index fbe387d..8ce58ba 100644 --- a/src/api/src/main.py +++ b/src/api/src/main.py @@ -2,6 +2,7 @@ import asyncio from enum import Enum +from os import getenv from pathlib import Path from typing import Optional from zipfile import ZipFile @@ -17,7 +18,6 @@ from fastapi.responses import ( StreamingResponse, ) from fastapi.staticfiles import StaticFiles -from os import getenv from create_book import ( EPUBGenerator, @@ -37,7 +37,7 @@ from create_book.parser import clean_tree, fetch_tree_images app = FastAPI() BUILD_PATH = Path(__file__).parent / "build" -feature_flag = True if getenv("VITE_FEATURE_FLAG") == "true" else False +PDFS_ENABLED = True if getenv("VITE_ENABLE_PDFS") == "true" else False class RequestCancelledMiddleware: @@ -195,7 +195,7 @@ async def handle_download( book = EPUBGenerator(metadata, part_trees, cover_data, images) media_type = "application/epub+zip" case DownloadFormat.pdf: - if not feature_flag: + if not PDFS_ENABLED: logger.error("PDF downloads not enabled.") return HTMLResponse( status_code=403, @@ -224,7 +224,7 @@ async def handle_download( yield chunk return StreamingResponse( - book_buffer if feature_flag else iterfile(), + book_buffer if PDFS_ENABLED else iterfile(), media_type=media_type, headers={ "Content-Disposition": f'attachment; filename="{slugify(metadata["title"])}_{story_id}{"_images" if download_images else ""}.{format.value}"', # Thanks https://stackoverflow.com/a/72729058 diff --git a/src/frontend/src/routes/+page.svelte b/src/frontend/src/routes/+page.svelte index 3ef6fb1..d8459e2 100644 --- a/src/frontend/src/routes/+page.svelte +++ b/src/frontend/src/routes/+page.svelte @@ -1,5 +1,5 @@