Merge pull request #2166 from pbiering/extend-item-verify
extend item verification on command line
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
## 3.7.6.dev
|
||||
* Extension: item verification on commandline
|
||||
|
||||
## 3.7.5
|
||||
* Add: [sharing] conversion_bday_summary_template (customize summary)
|
||||
|
||||
@@ -37,6 +37,7 @@ from typing import (Any, Callable, List, MutableMapping, Optional, Sequence,
|
||||
|
||||
import vobject
|
||||
|
||||
import radicale.item as radicale_item
|
||||
from radicale import storage # noqa:F401
|
||||
from radicale import pathutils, sharing, utils
|
||||
from radicale.item import filter as radicale_filter
|
||||
@@ -377,7 +378,41 @@ def verify(file: str, encoding: str):
|
||||
logger.info("Item content (hexdump/lines):\n%s", utils.hexdump_lines(content))
|
||||
return False
|
||||
else:
|
||||
logger.info("Verifying item: %s successful", file)
|
||||
logger.info("Verifying item(vobject/read_components): %s successful", file)
|
||||
|
||||
try:
|
||||
tag = radicale_item.predict_tag_of_whole_collection(vobject_items)
|
||||
if tag is not None:
|
||||
radicale_item.check_and_sanitize_items(vobject_items, tag=tag)
|
||||
else:
|
||||
raise ValueError("collection tag cannot be predicted")
|
||||
except Exception as e:
|
||||
logger.error("Verifying item: %s problem: %s", file, e)
|
||||
logger.warning("Item content:\n%s", utils.textwrap_str(content))
|
||||
return False
|
||||
else:
|
||||
logger.info("Verifying item(radicale/check_and_sanitze): %s successful", file)
|
||||
|
||||
vobject_item, = vobject_items
|
||||
|
||||
try:
|
||||
item = radicale_item.Item(collection_path="verify", vobject_item=vobject_item)
|
||||
except Exception as e:
|
||||
logger.error("Verifying item: %s problem: %s", file, e)
|
||||
logger.warning("Item content:\n%s", utils.textwrap_str(content))
|
||||
return False
|
||||
else:
|
||||
logger.info("Verifying item(radicale/Item): %s successful", file)
|
||||
|
||||
try:
|
||||
item.prepare()
|
||||
except Exception as e:
|
||||
logger.error("Verifying item: %s problem: %s", file, e)
|
||||
logger.warning("Item content:\n%s", utils.textwrap_str(content))
|
||||
return False
|
||||
else:
|
||||
logger.info("Verifying item(radicale/prepare): %s successful", file)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user