Test data folder writable with file

* Fixes #1441
This commit is contained in:
JonnyWong16 2021-06-18 09:40:17 -07:00
commit e99063d6c0
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 11 additions and 1 deletions

1
.gitignore vendored
View file

@ -23,6 +23,7 @@ newsletters/*
*.mmdb
version.txt
branch.txt
.TEST
# HTTPS Cert/Key #
##################

View file

@ -212,9 +212,18 @@ def main():
'Could not create data directory: ' + plexpy.DATA_DIR + '. Exiting....')
# Make sure the DATA_DIR is writeable
if not os.access(plexpy.DATA_DIR, os.W_OK):
test_file = os.path.join(plexpy.DATA_DIR, '.TEST')
try:
with open(test_file, 'w'):
pass
except IOError:
raise SystemExit(
'Cannot write to the data directory: ' + plexpy.DATA_DIR + '. Exiting...')
finally:
try:
os.remove(test_file)
except OSError:
pass
# Put the database in the DATA_DIR
plexpy.DB_FILE = os.path.join(plexpy.DATA_DIR, database.FILENAME)