From 9e769f8cd88c70ce20f48acb6e9dd74e0b5adf9d Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 29 Jan 2024 00:31:03 +0100 Subject: [PATCH] Fix startup when PEDALBOARD_TMP_DIR exists but FS is read-only Signed-off-by: falkTX --- mod/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mod/__init__.py b/mod/__init__.py index bab760f8..3998841e 100644 --- a/mod/__init__.py +++ b/mod/__init__.py @@ -59,9 +59,14 @@ def check_environment(): # create temp dirs if not os.path.exists(DOWNLOAD_TMP_DIR): os.makedirs(DOWNLOAD_TMP_DIR) + if os.path.exists(PEDALBOARD_TMP_DIR): - shutil.rmtree(PEDALBOARD_TMP_DIR) - os.makedirs(PEDALBOARD_TMP_DIR) + try: + shutil.rmtree(PEDALBOARD_TMP_DIR) + except OSError: + pass + else: + os.makedirs(PEDALBOARD_TMP_DIR) # remove temp files for path in (CAPTURE_PATH, PLAYBACK_PATH, UPDATE_CC_FIRMWARE_FILE): @@ -105,7 +110,7 @@ def check_environment(): if os.path.exists(UPDATE_MOD_OS_HERLPER_FILE): os.remove(UPDATE_MOD_OS_HERLPER_FILE) - os.sync() + os_sync() return True