From 60254aaada76a0247ef572d3fec40610530aea2d Mon Sep 17 00:00:00 2001 From: benne238 Date: Mon, 12 Jul 2021 12:07:46 -0400 Subject: [PATCH] modified logic to avoid directly reading lock file contents due to possible read/write permission issues --- src/webqueue2api/parser/item.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/webqueue2api/parser/item.py b/src/webqueue2api/parser/item.py index 31d9f7b..928ddc4 100644 --- a/src/webqueue2api/parser/item.py +++ b/src/webqueue2api/parser/item.py @@ -1096,11 +1096,9 @@ def __check_is_locked(self) -> Union[str, bool]: """ lock_file = str(self.path) + ".lck" if os.path.exists(lock_file): - with open(lock_file) as file: - lock_info = file.readline().split(" ") - locked_by = lock_info[4] - locked_using = lock_info[1] - return f"{self.queue} {self.number} is locked by {locked_by} using {locked_using}" + lock_file = Path(lock_file) + lock_file_owner = lock_file.owner() + return f"{self.queue} {self.number} is locked by {lock_file_owner}." else: return False