소스 검색

Add option to close lock file

Close the lock file, when no more clients are waiting.
This option is not very useful in general, but on Windows files that are opened cannot be deleted. This causes tests to fail, because the deletion of the temporary filesystem folder fails.
Unrud 9 년 전
부모
커밋
3f5dd70580
2개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      radicale/config.py
  2. 4 0
      radicale/storage.py

+ 2 - 1
radicale/config.py

@@ -59,7 +59,8 @@ INITIAL_CONFIG = {
         "filesystem_folder": os.path.expanduser(
             "~/.config/radicale/collections"),
         "fsync": "True",
-        "hook": ""},
+        "hook": "",
+        "close_lock_file": "False"},
     "logging": {
         "config": "/etc/radicale/logging",
         "debug": "False",

+ 4 - 0
radicale/storage.py

@@ -802,3 +802,7 @@ class Collection(BaseCollection):
                     cls._lock_file_locked = False
                 if cls._waiters:
                     cls._waiters[0].notify()
+                if (cls.configuration.getboolean("storage", "close_lock_file")
+                        and cls._readers == 0 and not cls._waiters):
+                    cls._lock_file.close()
+                    cls._lock_file = None