Move filesystem_fsync config from section storage to internal

This commit is contained in:
Unrud 2018-08-18 12:56:39 +02:00
parent 4282ea46e4
commit 8281769edf
6 changed files with 10 additions and 15 deletions

5
config
View File

@ -103,11 +103,6 @@
# storage externally while Radicale is running if disabled. # storage externally while Radicale is running if disabled.
#filesystem_locking = True #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) # Delete sync token that are older (seconds)
#max_sync_token_age = 2592000 #max_sync_token_age = 2592000

View File

@ -164,10 +164,6 @@ INITIAL_CONFIG = OrderedDict([
"value": 2592000, # 30 days "value": 2592000, # 30 days
"help": "delete sync token that are older", "help": "delete sync token that are older",
"type": int}), "type": int}),
("filesystem_fsync", {
"value": "True",
"help": "sync all changes to filesystem during requests",
"type": bool}),
("hook", { ("hook", {
"value": "", "value": "",
"help": "command that is run after changes to storage", "help": "command that is run after changes to storage",
@ -189,6 +185,10 @@ INITIAL_CONFIG = OrderedDict([
"type": bool})]))]) "type": bool})]))])
# Default configuration for "internal" settings # Default configuration for "internal" settings
INTERNAL_CONFIG = OrderedDict([ INTERNAL_CONFIG = OrderedDict([
("filesystem_fsync", {
"value": "True",
"help": "sync all changes to filesystem during requests",
"type": bool}),
("internal_server", { ("internal_server", {
"value": "False", "value": "False",
"help": "the internal server is used", "help": "the internal server is used",

View File

@ -784,7 +784,7 @@ class Collection(BaseCollection):
@classmethod @classmethod
def _fsync(cls, fd): 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"): if os.name == "posix" and hasattr(fcntl, "F_FULLFSYNC"):
fcntl.fcntl(fd, fcntl.F_FULLFSYNC) fcntl.fcntl(fd, fcntl.F_FULLFSYNC)
else: else:
@ -797,7 +797,7 @@ class Collection(BaseCollection):
This only works on POSIX and does nothing on other systems. 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 return
if os.name == "posix": if os.name == "posix":
try: try:

View File

@ -43,7 +43,7 @@ class TestBaseAuthRequests(BaseTest):
self.colpath = tempfile.mkdtemp() self.colpath = tempfile.mkdtemp()
self.configuration["storage"]["filesystem_folder"] = self.colpath self.configuration["storage"]["filesystem_folder"] = self.colpath
# Disable syncing to disk for better performance # 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 # Required on Windows, doesn't matter on Unix
self.configuration["storage"]["filesystem_close_lock_file"] = "True" self.configuration["storage"]["filesystem_close_lock_file"] = "True"
# Set incorrect authentication delay to a very low value # Set incorrect authentication delay to a very low value

View File

@ -1427,7 +1427,7 @@ class BaseFileSystemTest(BaseTest):
self.colpath = tempfile.mkdtemp() self.colpath = tempfile.mkdtemp()
self.configuration["storage"]["filesystem_folder"] = self.colpath self.configuration["storage"]["filesystem_folder"] = self.colpath
# Disable syncing to disk for better performance # Disable syncing to disk for better performance
self.configuration["storage"]["filesystem_fsync"] = "False" self.configuration["internal"]["filesystem_fsync"] = "False"
self.application = Application(self.configuration) self.application = Application(self.configuration)
def teardown(self): def teardown(self):
@ -1440,7 +1440,7 @@ class TestMultiFileSystem(BaseFileSystemTest, BaseRequestsMixIn):
def test_fsync(self): def test_fsync(self):
"""Create a directory and file with syncing enabled.""" """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/") status, _, _ = self.request("MKCALENDAR", "/calendar.ics/")
assert status == 201 assert status == 201

View File

@ -36,7 +36,7 @@ class TestBaseAuthRequests(BaseTest):
self.colpath = tempfile.mkdtemp() self.colpath = tempfile.mkdtemp()
self.configuration["storage"]["filesystem_folder"] = self.colpath self.configuration["storage"]["filesystem_folder"] = self.colpath
# Disable syncing to disk for better performance # Disable syncing to disk for better performance
self.configuration["storage"]["filesystem_fsync"] = "False" self.configuration["internal"]["filesystem_fsync"] = "False"
def teardown(self): def teardown(self):
shutil.rmtree(self.colpath) shutil.rmtree(self.colpath)