Create upload folder if it does not exist
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
@ -28,6 +29,9 @@ class Settings:
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
sys.exit("discord-embed: Environment variable 'UPLOAD_FOLDER' is missing!")
|
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.
|
# We check if the upload folder ends with a forward slash. If it does, we remove it.
|
||||||
if upload_folder.endswith("/"):
|
if upload_folder.endswith("/"):
|
||||||
upload_folder = upload_folder[:-1]
|
upload_folder = upload_folder[:-1]
|
||||||
|
Reference in New Issue
Block a user