mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-29 15:31:28 +00:00
Make sure jobs file exists on read
This commit is contained in:
parent
1b1bb4966a
commit
f940a23e7e
|
@ -69,6 +69,10 @@ class ReadUserData(object):
|
||||||
elif file_type == UserDataFiles.TOKENS:
|
elif file_type == UserDataFiles.TOKENS:
|
||||||
self.userdata_file = open(TOKENS_FILE, "r", encoding="utf-8")
|
self.userdata_file = open(TOKENS_FILE, "r", encoding="utf-8")
|
||||||
elif file_type == UserDataFiles.JOBS:
|
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")
|
self.userdata_file = open(JOBS_FILE, "r", encoding="utf-8")
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown file type")
|
raise ValueError("Unknown file type")
|
||||||
|
|
Loading…
Reference in a new issue