浏览代码

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