Skip to content

Commit

Permalink
Do not autocreate .props files for multifilesystem backend
Browse files Browse the repository at this point in the history
This is required as we do not want .props files to be created for nodes,
otherwise they'll stop being considered as nodes, which will break
discovery of calendars.

This fixes Kozea#208
  • Loading branch information
vuntz committed Sep 15, 2014
1 parent a688449 commit 873872d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions radicale/storage/multifilesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
"""

import os
import json
import shutil
import time
import sys

from contextlib import contextmanager
from . import filesystem
from .. import ical

Expand Down Expand Up @@ -96,3 +98,20 @@ def last_modified(self):
os.path.getmtime(os.path.join(self._path, filename))
for filename in os.listdir(self._path)] or [0])
return time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(last))

@property
@contextmanager
def props(self):
# On enter
properties = {}
if os.path.exists(self._props_path):
with open(self._props_path) as prop_file:
properties.update(json.load(prop_file))
old_properties = properties.copy()
yield properties
# On exit
if os.path.exists(self._props_path):
self._create_dirs()
if old_properties != properties:
with open(self._props_path, "w") as prop_file:
json.dump(properties, prop_file)

0 comments on commit 873872d

Please sign in to comment.