mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-01 18:18:31 +00:00
Add option to disable syncing to disk
Disabling syncing increases the risk of data loss when the system crashes or power fails. On the positive it can increase the performance to a great extent.
This commit is contained in:
parent
c336e0581e
commit
f5f52582a1
3 changed files with 15 additions and 6 deletions
|
@ -58,6 +58,7 @@ INITIAL_CONFIG = {
|
|||
"type": "multifilesystem",
|
||||
"filesystem_folder": os.path.expanduser(
|
||||
"~/.config/radicale/collections"),
|
||||
"fsync": "True",
|
||||
"hook": ""},
|
||||
"logging": {
|
||||
"config": "/etc/radicale/logging",
|
||||
|
|
|
@ -393,10 +393,11 @@ class Collection(BaseCollection):
|
|||
delete=False, prefix=".Radicale.tmp-")
|
||||
try:
|
||||
yield tmp
|
||||
if os.name == "posix" and hasattr(fcntl, "F_FULLFSYNC"):
|
||||
fcntl.fcntl(tmp.fileno(), fcntl.F_FULLFSYNC)
|
||||
else:
|
||||
os.fsync(tmp.fileno())
|
||||
if self.configuration.getboolean("storage", "fsync"):
|
||||
if os.name == "posix" and hasattr(fcntl, "F_FULLFSYNC"):
|
||||
fcntl.fcntl(tmp.fileno(), fcntl.F_FULLFSYNC)
|
||||
else:
|
||||
os.fsync(tmp.fileno())
|
||||
tmp.close()
|
||||
os.rename(tmp.name, path)
|
||||
except:
|
||||
|
@ -413,13 +414,15 @@ class Collection(BaseCollection):
|
|||
return file_name
|
||||
raise FileExistsError(errno.EEXIST, "No usable file name found")
|
||||
|
||||
@staticmethod
|
||||
def _sync_directory(path):
|
||||
@classmethod
|
||||
def _sync_directory(cls, path):
|
||||
"""Sync directory to disk.
|
||||
|
||||
This only works on POSIX and does nothing on other systems.
|
||||
|
||||
"""
|
||||
if not cls.configuration.getboolean("storage", "fsync"):
|
||||
return
|
||||
if os.name == "posix":
|
||||
fd = os.open(path, 0)
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue