From e99063d6c0a17c37e591123b0a49fe19f8f1d441 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Fri, 18 Jun 2021 09:40:17 -0700 Subject: [PATCH] Test data folder writable with file * Fixes #1441 --- .gitignore | 1 + Tautulli.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 25777166..e486aca1 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ newsletters/* *.mmdb version.txt branch.txt +.TEST # HTTPS Cert/Key # ################## diff --git a/Tautulli.py b/Tautulli.py index 069f771b..1b19281d 100755 --- a/Tautulli.py +++ b/Tautulli.py @@ -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)