Create upload folder if it does not exist

This commit is contained in:
2022-01-03 20:40:57 +01:00
parent d060c67197
commit a993abce39

View File

@ -1,4 +1,5 @@
import os
import pathlib
import sys
from dotenv import load_dotenv
@ -28,6 +29,9 @@ class Settings:
except KeyError:
sys.exit("discord-embed: Environment variable 'UPLOAD_FOLDER' is missing!")
# Create upload_folder if it doesn't exist.
pathlib.Path(upload_folder).mkdir(parents=True, exist_ok=True)
# We check if the upload folder ends with a forward slash. If it does, we remove it.
if upload_folder.endswith("/"):
upload_folder = upload_folder[:-1]