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.
This commit is contained in:
Unrud 2016-08-11 03:34:08 +02:00
parent 35d12ee97e
commit 3f5dd70580
2 changed files with 6 additions and 1 deletions

View File

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

View File

@ -802,3 +802,7 @@ class Collection(BaseCollection):
cls._lock_file_locked = False cls._lock_file_locked = False
if cls._waiters: if cls._waiters:
cls._waiters[0].notify() 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