commit
071a829af8
@ -580,7 +580,17 @@ class Collection(BaseCollection):
|
|||||||
if href is None:
|
if href is None:
|
||||||
# Delete the collection
|
# Delete the collection
|
||||||
if os.path.isdir(self._filesystem_path):
|
if os.path.isdir(self._filesystem_path):
|
||||||
shutil.rmtree(self._filesystem_path)
|
parent_dir = os.path.dirname(self._filesystem_path)
|
||||||
|
try:
|
||||||
|
os.rmdir(self._filesystem_path)
|
||||||
|
except OSError:
|
||||||
|
with TemporaryDirectory(prefix=".Radicale.tmp-",
|
||||||
|
dir=parent_dir) as tmp_dir:
|
||||||
|
os.rename(self._filesystem_path, os.path.join(
|
||||||
|
tmp_dir, os.path.basename(self._filesystem_path)))
|
||||||
|
sync_directory(parent_dir)
|
||||||
|
else:
|
||||||
|
sync_directory(parent_dir)
|
||||||
else:
|
else:
|
||||||
# Delete an item
|
# Delete an item
|
||||||
if not is_safe_filesystem_path_component(href):
|
if not is_safe_filesystem_path_component(href):
|
||||||
@ -593,6 +603,7 @@ class Collection(BaseCollection):
|
|||||||
if etag and etag != get_etag(text):
|
if etag and etag != get_etag(text):
|
||||||
raise EtagMismatchError(etag, get_etag(text))
|
raise EtagMismatchError(etag, get_etag(text))
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
sync_directory(os.path.dirname(path))
|
||||||
|
|
||||||
def get_meta(self, key):
|
def get_meta(self, key):
|
||||||
if os.path.exists(self._props_path):
|
if os.path.exists(self._props_path):
|
||||||
|
@ -163,6 +163,31 @@ class BaseRequests:
|
|||||||
assert status == 200
|
assert status == 200
|
||||||
assert "DAV" in headers
|
assert "DAV" in headers
|
||||||
|
|
||||||
|
def test_delete_collection(self):
|
||||||
|
"""Delete a collection."""
|
||||||
|
self.request("MKCOL", "/calendar.ics/")
|
||||||
|
event = get_file_content("event1.ics")
|
||||||
|
self.request("PUT", "/calendar.ics/event1.ics", event)
|
||||||
|
status, headers, answer = self.request("DELETE", "/calendar.ics/")
|
||||||
|
assert status == 200
|
||||||
|
assert "href>/calendar.ics/</" in answer
|
||||||
|
status, headers, answer = self.request("GET", "/calendar.ics/")
|
||||||
|
assert status == 404
|
||||||
|
|
||||||
|
def test_delete_root_collection(self):
|
||||||
|
"""Delete the root collection."""
|
||||||
|
self.request("MKCOL", "/calendar.ics/")
|
||||||
|
event = get_file_content("event1.ics")
|
||||||
|
self.request("PUT", "/event1.ics", event)
|
||||||
|
self.request("PUT", "/calendar.ics/event1.ics", event)
|
||||||
|
status, headers, answer = self.request("DELETE", "/")
|
||||||
|
assert status == 200
|
||||||
|
assert "href>/</" in answer
|
||||||
|
status, headers, answer = self.request("GET", "/calendar.ics/")
|
||||||
|
assert status == 404
|
||||||
|
status, headers, answer = self.request("GET", "/event1.ics")
|
||||||
|
assert status == 404
|
||||||
|
|
||||||
def test_multiple_events_with_same_uid(self):
|
def test_multiple_events_with_same_uid(self):
|
||||||
"""Add two events with the same UID."""
|
"""Add two events with the same UID."""
|
||||||
self.request("MKCOL", "/calendar.ics/")
|
self.request("MKCOL", "/calendar.ics/")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user