Skip to content

Commit 13b9031

Browse files
committed
Ensure /data/images/ directory exists before processing PDFs
1 parent adda17d commit 13b9031

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ def clear_cache():
251251
@app.cli.command()
252252
@click.argument("pattern")
253253
def update_docs(pattern="*"):
254+
Path("/data/images").mkdir(parents=True, exist_ok=True)
254255
# only add documents that are not already entered
255256
for pdf_path in Path("/data" + "/pdfs").glob(pattern + ".pdf"):
256257
try:
@@ -290,6 +291,7 @@ def clear_data():
290291
db.create_all()
291292
db.session.commit()
292293

294+
Path("/data/images").mkdir(parents=True, exist_ok=True)
293295
for pdf_path in Path("/data/pdfs").glob("*.pdf"):
294296
proc_pdf(pdf_path)
295297

@@ -299,6 +301,7 @@ def clear_data():
299301
@click.option("--force", is_flag=True, help="Regenerate existing images")
300302
def generate_images(pattern="*", force=False):
301303
"""Generate JPEG and AVIF images from PDFs. Usage: flask generate-images '*'"""
304+
Path("/data/images").mkdir(parents=True, exist_ok=True)
302305
for pdf_path in sorted(Path("/data/pdfs").glob(pattern + ".pdf")):
303306
if (
304307
pdf_path.stem.endswith("_en")

0 commit comments

Comments
 (0)