From 3f5dd70580e26bf2fa6c6d2ce4faf32008243cf6 Mon Sep 17 00:00:00 2001 From: Unrud Date: Thu, 11 Aug 2016 03:34:08 +0200 Subject: [PATCH 1/2] 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. --- radicale/config.py | 3 ++- radicale/storage.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/radicale/config.py b/radicale/config.py index 1e02656..5076ffa 100644 --- a/radicale/config.py +++ b/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", diff --git a/radicale/storage.py b/radicale/storage.py index 594dc06..9fabfb3 100644 --- a/radicale/storage.py +++ b/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 \ No newline at end of file From 7a01f905de108f692129c323f5bd2115bffa3490 Mon Sep 17 00:00:00 2001 From: Unrud Date: Thu, 11 Aug 2016 03:36:17 +0200 Subject: [PATCH 2/2] Enable close_lock_file for tests --- radicale/tests/test_base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/radicale/tests/test_base.py b/radicale/tests/test_base.py index 2e39fc4..1ea8c1f 100644 --- a/radicale/tests/test_base.py +++ b/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):