From 0f39b38dc3dc40f37b592fcfea4716e6f3266458 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Sat, 17 Jun 2023 13:42:36 -0700 Subject: [PATCH] [DOCS] Actionable message for file lock errors (#634) * [DOCS] Actionable message for file lock errors" * pylint --- src/ytdl_sub/utils/file_lock.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ytdl_sub/utils/file_lock.py b/src/ytdl_sub/utils/file_lock.py index 2e21acfe..e78209dc 100644 --- a/src/ytdl_sub/utils/file_lock.py +++ b/src/ytdl_sub/utils/file_lock.py @@ -44,7 +44,19 @@ else: / str(working_directory_path).replace("/", "_") ) - lock_file = open(lock_file_path, "w", encoding="utf-8") + try: + lock_file = open(lock_file_path, "w", encoding="utf-8") + except FileNotFoundError as exc: + # pylint: disable=line-too-long + raise ValidationException( + "Failed to create a file-lock to prevent multiple instances of ytdl-sub from " + "colliding with each other. If you get this error, it typically means it tried to " + "create the file in a directory that is not a part of the same filesystem that " + "ytdl-sub is running on. See " + "https://ytdl-sub.readthedocs.io/en/latest/config.html#ytdl_sub.config.config_validator.ConfigOptions.lock_directory " + "on how to change the directory that this lock gets written to." + ) from exc + # pylint: enable=line-too-long try: fcntl.lockf(lock_file, fcntl.LOCK_EX | fcntl.LOCK_NB)