From 8e9e429a912725ffdfc0aaa85af37f420e87a3c4 Mon Sep 17 00:00:00 2001 From: arkohut <39525455+arkohut@users.noreply.github.com> Date: Sun, 9 Jun 2024 23:19:16 +0800 Subject: [PATCH 1/2] fix: tolerant readonly filesystem for copy favicon to static dir --- backend/config.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/config.py b/backend/config.py index fcced4f61..9ee146040 100644 --- a/backend/config.py +++ b/backend/config.py @@ -310,6 +310,12 @@ if frontend_favicon.exists(): shutil.copyfile(frontend_favicon, STATIC_DIR / "favicon.png") except PermissionError: logging.error(f"No write permission to {STATIC_DIR / 'favicon.png'}") + except OSError as e: + if e.errno == 30: # Read-only file system + logging.error(f"Read-only file system: {STATIC_DIR / 'favicon.png'}") + else: + logging.error(f"OS error occurred: {e}") + else: logging.warning(f"Frontend favicon not found at {frontend_favicon}") From d20f6cb45baf3416287e92229ac2e19dd7cb85da Mon Sep 17 00:00:00 2001 From: arkohut <39525455+arkohut@users.noreply.github.com> Date: Mon, 10 Jun 2024 21:27:35 +0800 Subject: [PATCH 2/2] fix: use Exception to handle all errors --- backend/config.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/backend/config.py b/backend/config.py index 9ee146040..0859d2b70 100644 --- a/backend/config.py +++ b/backend/config.py @@ -308,13 +308,8 @@ frontend_favicon = FRONTEND_BUILD_DIR / "favicon.png" if frontend_favicon.exists(): try: shutil.copyfile(frontend_favicon, STATIC_DIR / "favicon.png") - except PermissionError: - logging.error(f"No write permission to {STATIC_DIR / 'favicon.png'}") - except OSError as e: - if e.errno == 30: # Read-only file system - logging.error(f"Read-only file system: {STATIC_DIR / 'favicon.png'}") - else: - logging.error(f"OS error occurred: {e}") + except Exception as e: + logging.error(f"An error occurred: {e}") else: logging.warning(f"Frontend favicon not found at {frontend_favicon}")