From 2772a11d8460920df727a237d91b33cc85da8e08 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Sat, 5 Jul 2025 13:27:12 -0400 Subject: [PATCH] Fix Windows exclusive lock test --- src/utils/file_lock.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/utils/file_lock.py b/src/utils/file_lock.py index e90f86b..f2c1aa1 100644 --- a/src/utils/file_lock.py +++ b/src/utils/file_lock.py @@ -20,10 +20,21 @@ def exclusive_lock( """ path = Path(path) path.parent.mkdir(parents=True, exist_ok=True) + path.touch(exist_ok=True) + flags = portalocker.LockFlags.EXCLUSIVE if timeout is None: - lock = portalocker.Lock(str(path), mode="a+b") + lock = portalocker.Lock( + str(path), + mode="r+b", + flags=flags, + ) else: - lock = portalocker.Lock(str(path), mode="a+b", timeout=timeout) + lock = portalocker.Lock( + str(path), + mode="r+b", + timeout=timeout, + flags=flags, + ) with lock as fh: yield fh