summaryrefslogtreecommitdiffstats
path: root/deluge
diff options
context:
space:
mode:
authordoadin <tbkizle@gmail.com>2022-02-02 18:12:23 -0500
committerCalum Lind <calumlind+deluge@gmail.com>2022-02-03 22:46:33 +0000
commit8b0c8392b63f4af976c3046093f3ead96eddddc8 (patch)
tree24020f6f0cafb97fcd8a6bda0eb4c5e6e29c5d43 /deluge
parent222aeed2f3bfc058739835afb4007955a92dde05 (diff)
downloaddeluge-8b0c8392b63f4af976c3046093f3ead96eddddc8.tar.gz
deluge-8b0c8392b63f4af976c3046093f3ead96eddddc8.tar.bz2
deluge-8b0c8392b63f4af976c3046093f3ead96eddddc8.zip
[Log] Fix crash logging to Windows protected folder
Have the log dir be a protected windows folder and Deluge crashes. Windows blocks access to the dir and so it fails. It will fail trying to write to any protected folder. Should probably just pass on the error maybe and maybe log to stdout and log a message saying access was blocked or something. .\deluge-debug -L debug -l E:\Documents\deluge.log ... Failed to execute script 'deluge-debug-script' due to unhandled exception! Closes: https://dev.deluge-torrent.org/ticket/3502 Closes: https://github.com/deluge-torrent/deluge/pull/358
Diffstat (limited to 'deluge')
-rw-r--r--deluge/log.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/deluge/log.py b/deluge/log.py
index 265186e7e..6ce6c2df6 100644
--- a/deluge/log.py
+++ b/deluge/log.py
@@ -155,7 +155,12 @@ def setup_logger(
handler_cls = getattr(
logging.handlers, 'WatchedFileHandler', logging.FileHandler
)
- handler = handler_cls(filename, mode=filemode, encoding='utf-8')
+ try:
+ handler = handler_cls(filename, mode=filemode, encoding='utf-8')
+ except FileNotFoundError:
+ handler = logging.StreamHandler(stream=output_stream)
+ log = logging.getLogger(__name__)
+ log.error(f'Unable to write to log file `{filename}`')
else:
handler = logging.StreamHandler(stream=output_stream)