Skip to content

Commit f6bc8a4

Browse files
committed
Ensure directory exists before managing PDFs in utils.py
1 parent ef52d85 commit f6bc8a4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

utils/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import streamlit
22
from pathlib import Path
33

4-
54
def start_chatbot(st, directory, function):
65
directory = Path(directory) if isinstance(directory, str) else directory
76
if len(list(directory.glob("*.pdf"))) == 0:
@@ -23,6 +22,8 @@ def manage_pdfs(st: streamlit, directory: Path, pdf_list: list):
2322
None
2423
"""
2524
directory = Path(directory) if isinstance(directory, str) else directory
25+
if not directory.exists():
26+
directory.mkdir(parents=True, exist_ok=True)
2627
for existing_file in directory.glob("*.pdf"):
2728
existing_file.unlink()
2829
for new_file in pdf_list:

0 commit comments

Comments
 (0)