Explorar o código

Merge pull request #476 from Unrud/closelockfile

Add option to close lock file
Guillaume Ayoub %!s(int64=9) %!d(string=hai) anos
pai
achega
e66a35e996
Modificáronse 3 ficheiros con 8 adicións e 1 borrados
  1. 2 1
      radicale/config.py
  2. 4 0
      radicale/storage.py
  3. 2 0
      radicale/tests/test_base.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

@@ -793,3 +793,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

+ 2 - 0
radicale/tests/test_base.py

@@ -813,6 +813,8 @@ class BaseFileSystemTest(BaseTest):
         self.configuration.set("storage", "filesystem_folder", self.colpath)
         # Disable syncing to disk for better performance
         self.configuration.set("storage", "fsync", "False")
+        # Required on Windows, doesn't matter on Unix
+        self.configuration.set("storage", "close_lock_file", "True")
         self.application = Application(self.configuration, self.logger)
 
     def teardown(self):