From 8281769edff54747d1a242b69ddb5172ce2b00c9 Mon Sep 17 00:00:00 2001 From: Unrud Date: Sat, 18 Aug 2018 12:56:39 +0200 Subject: [PATCH] Move filesystem_fsync config from section storage to internal --- config | 5 ----- radicale/config.py | 8 ++++---- radicale/storage.py | 4 ++-- radicale/tests/test_auth.py | 2 +- radicale/tests/test_base.py | 4 ++-- radicale/tests/test_rights.py | 2 +- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/config b/config index d724a88a..93172ac8 100644 --- a/config +++ b/config @@ -103,11 +103,6 @@ # storage externally while Radicale is running if disabled. #filesystem_locking = True -# Sync all changes to disk during requests. (This can impair performance.) -# Disabling it increases the risk of data loss, when the system crashes or -# power fails! -#filesystem_fsync = True - # Delete sync token that are older (seconds) #max_sync_token_age = 2592000 diff --git a/radicale/config.py b/radicale/config.py index 9c3fc7a6..97141f78 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -164,10 +164,6 @@ INITIAL_CONFIG = OrderedDict([ "value": 2592000, # 30 days "help": "delete sync token that are older", "type": int}), - ("filesystem_fsync", { - "value": "True", - "help": "sync all changes to filesystem during requests", - "type": bool}), ("hook", { "value": "", "help": "command that is run after changes to storage", @@ -189,6 +185,10 @@ INITIAL_CONFIG = OrderedDict([ "type": bool})]))]) # Default configuration for "internal" settings INTERNAL_CONFIG = OrderedDict([ + ("filesystem_fsync", { + "value": "True", + "help": "sync all changes to filesystem during requests", + "type": bool}), ("internal_server", { "value": "False", "help": "the internal server is used", diff --git a/radicale/storage.py b/radicale/storage.py index ffd89b8f..9189030d 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -784,7 +784,7 @@ class Collection(BaseCollection): @classmethod def _fsync(cls, fd): - if cls.configuration.getboolean("storage", "filesystem_fsync"): + if cls.configuration.getboolean("internal", "filesystem_fsync"): if os.name == "posix" and hasattr(fcntl, "F_FULLFSYNC"): fcntl.fcntl(fd, fcntl.F_FULLFSYNC) else: @@ -797,7 +797,7 @@ class Collection(BaseCollection): This only works on POSIX and does nothing on other systems. """ - if not cls.configuration.getboolean("storage", "filesystem_fsync"): + if not cls.configuration.getboolean("internal", "filesystem_fsync"): return if os.name == "posix": try: diff --git a/radicale/tests/test_auth.py b/radicale/tests/test_auth.py index 7c8b36dd..cf627579 100644 --- a/radicale/tests/test_auth.py +++ b/radicale/tests/test_auth.py @@ -43,7 +43,7 @@ class TestBaseAuthRequests(BaseTest): self.colpath = tempfile.mkdtemp() self.configuration["storage"]["filesystem_folder"] = self.colpath # Disable syncing to disk for better performance - self.configuration["storage"]["filesystem_fsync"] = "False" + self.configuration["internal"]["filesystem_fsync"] = "False" # Required on Windows, doesn't matter on Unix self.configuration["storage"]["filesystem_close_lock_file"] = "True" # Set incorrect authentication delay to a very low value diff --git a/radicale/tests/test_base.py b/radicale/tests/test_base.py index 3c4e3caf..cc1cfdfe 100644 --- a/radicale/tests/test_base.py +++ b/radicale/tests/test_base.py @@ -1427,7 +1427,7 @@ class BaseFileSystemTest(BaseTest): self.colpath = tempfile.mkdtemp() self.configuration["storage"]["filesystem_folder"] = self.colpath # Disable syncing to disk for better performance - self.configuration["storage"]["filesystem_fsync"] = "False" + self.configuration["internal"]["filesystem_fsync"] = "False" self.application = Application(self.configuration) def teardown(self): @@ -1440,7 +1440,7 @@ class TestMultiFileSystem(BaseFileSystemTest, BaseRequestsMixIn): def test_fsync(self): """Create a directory and file with syncing enabled.""" - self.configuration["storage"]["filesystem_fsync"] = "True" + self.configuration["internal"]["filesystem_fsync"] = "True" status, _, _ = self.request("MKCALENDAR", "/calendar.ics/") assert status == 201 diff --git a/radicale/tests/test_rights.py b/radicale/tests/test_rights.py index d55d2505..4d17eb57 100644 --- a/radicale/tests/test_rights.py +++ b/radicale/tests/test_rights.py @@ -36,7 +36,7 @@ class TestBaseAuthRequests(BaseTest): self.colpath = tempfile.mkdtemp() self.configuration["storage"]["filesystem_folder"] = self.colpath # Disable syncing to disk for better performance - self.configuration["storage"]["filesystem_fsync"] = "False" + self.configuration["internal"]["filesystem_fsync"] = "False" def teardown(self): shutil.rmtree(self.colpath)