Просмотр исходного кода

Move filesystem_fsync config from section storage to internal

Unrud 7 лет назад
Родитель
Сommit
8281769edf
6 измененных файлов с 10 добавлено и 15 удалено
  1. 0 5
      config
  2. 4 4
      radicale/config.py
  3. 2 2
      radicale/storage.py
  4. 1 1
      radicale/tests/test_auth.py
  5. 2 2
      radicale/tests/test_base.py
  6. 1 1
      radicale/tests/test_rights.py

+ 0 - 5
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
 

+ 4 - 4
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",

+ 2 - 2
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:

+ 1 - 1
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

+ 2 - 2
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
 

+ 1 - 1
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)