Make sure jobs file exists on read

This commit is contained in:
inexcode 2022-08-15 22:51:01 +04:00
parent 1b1bb4966a
commit f940a23e7e

View file

@ -69,6 +69,10 @@ class ReadUserData(object):
elif file_type == UserDataFiles.TOKENS:
self.userdata_file = open(TOKENS_FILE, "r", encoding="utf-8")
elif file_type == UserDataFiles.JOBS:
# Make sure file exists
if not os.path.isfile(JOBS_FILE):
with open(JOBS_FILE, "w", encoding="utf-8") as jobs_file:
jobs_file.write("[]")
self.userdata_file = open(JOBS_FILE, "r", encoding="utf-8")
else:
raise ValueError("Unknown file type")