commit
01bcdec729
@ -227,7 +227,12 @@ class Collection:
|
||||
|
||||
def list(self):
|
||||
"""List collection items."""
|
||||
for href in os.listdir(self._filesystem_path):
|
||||
try:
|
||||
hrefs = os.listdir(self._filesystem_path)
|
||||
except IOError:
|
||||
return
|
||||
|
||||
for href in hrefs:
|
||||
path = os.path.join(self._filesystem_path, href)
|
||||
if not href.endswith(".props") and os.path.isfile(path):
|
||||
with open(path, encoding=STORAGE_ENCODING) as fd:
|
||||
@ -348,8 +353,13 @@ class Collection:
|
||||
if os.path.exists(props_path):
|
||||
with open(props_path, encoding=STORAGE_ENCODING) as prop_file:
|
||||
properties.update(json.load(prop_file))
|
||||
|
||||
if value:
|
||||
properties[key] = value
|
||||
with open(props_path, "w", encoding=STORAGE_ENCODING) as prop_file:
|
||||
else:
|
||||
properties.pop(key, None)
|
||||
|
||||
with open(props_path, "w+", encoding=STORAGE_ENCODING) as prop_file:
|
||||
json.dump(properties, prop_file)
|
||||
|
||||
@property
|
||||
|
@ -442,18 +442,12 @@ def proppatch(path, xml_request, collection):
|
||||
href.text = _href(path)
|
||||
response.append(href)
|
||||
|
||||
with collection.props as collection_props:
|
||||
for short_name, value in props_to_set.items():
|
||||
if short_name.split(":")[-1] == "calendar-timezone":
|
||||
collection.replace(None, value)
|
||||
collection_props[short_name] = value
|
||||
collection.set_meta(short_name, value)
|
||||
_add_propstat_to(response, short_name, 200)
|
||||
|
||||
for short_name in props_to_remove:
|
||||
try:
|
||||
del collection_props[short_name]
|
||||
except KeyError:
|
||||
_add_propstat_to(response, short_name, 412)
|
||||
else:
|
||||
collection.set_meta(short_name, '')
|
||||
_add_propstat_to(response, short_name, 200)
|
||||
|
||||
return _pretty_xml(multistatus)
|
||||
@ -522,13 +516,14 @@ def report(path, xml_request, collection):
|
||||
if name:
|
||||
# Reference is an item
|
||||
path = "/".join(hreference.split("/")[:-1]) + "/"
|
||||
try:
|
||||
items = [collection.get(name)]
|
||||
except KeyError:
|
||||
item = collection.get(name)
|
||||
if item is None:
|
||||
multistatus.append(
|
||||
_item_response(hreference, found_item=False))
|
||||
continue
|
||||
|
||||
items = [item]
|
||||
|
||||
else:
|
||||
# Reference is a collection
|
||||
path = hreference
|
||||
|
Loading…
Reference in New Issue
Block a user