1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-08-13 18:50:53 +00:00

Merge pull request #1520 from pbiering/skip-broken-item

add option to skip broken item instead of throwing an exception
This commit is contained in:
Peter Bieringer 2024-06-09 18:05:22 +02:00 committed by GitHub
commit fe630b46ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 5 deletions

View file

@ -865,6 +865,12 @@ Delete sync-token that are older than the specified time. (seconds)
Default: `2592000` Default: `2592000`
#### skip_broken_item
Skip broken item instead of triggering an exception
Default: False
##### hook ##### hook
Command that is run after changes to storage. Take a look at the Command that is run after changes to storage. Take a look at the

3
config
View file

@ -99,6 +99,9 @@
# Delete sync token that are older (seconds) # Delete sync token that are older (seconds)
#max_sync_token_age = 2592000 #max_sync_token_age = 2592000
# Skip broken item instead of triggering an exception
#skip_broken_item = False
# Command that is run after changes to storage # Command that is run after changes to storage
# Example: ([ -d .git ] || git init) && git add -A && (git diff --cached --quiet || git commit -m "Changes by \"%(user)s\"") # Example: ([ -d .git ] || git init) && git add -A && (git diff --cached --quiet || git commit -m "Changes by \"%(user)s\"")
#hook = #hook =

View file

@ -211,6 +211,10 @@ DEFAULT_CONFIG_SCHEMA: types.CONFIG_SCHEMA = OrderedDict([
"value": "2592000", # 30 days "value": "2592000", # 30 days
"help": "delete sync token that are older", "help": "delete sync token that are older",
"type": positive_int}), "type": positive_int}),
("skip_broken_item", {
"value": "False",
"help": "skip broken item instead of triggering exception",
"type": bool}),
("hook", { ("hook", {
"value": "", "value": "",
"help": "command that is run after changes to storage", "help": "command that is run after changes to storage",

View file

@ -1,7 +1,8 @@
# This file is part of Radicale - CalDAV and CardDAV server # This file is part of Radicale - CalDAV and CardDAV server
# Copyright © 2014 Jean-Marc Martins # Copyright © 2014 Jean-Marc Martins
# Copyright © 2012-2017 Guillaume Ayoub # Copyright © 2012-2017 Guillaume Ayoub
# Copyright © 2017-2019 Unrud <unrud@outlook.com> # Copyright © 2017-2022 Unrud <unrud@outlook.com>
# Copyright © 2024-2024 Peter Bieringer <pb@bieringer.de>
# #
# This library is free software: you can redistribute it and/or modify # This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -40,6 +41,7 @@ class CollectionBase(storage.BaseCollection):
# Path should already be sanitized # Path should already be sanitized
self._path = pathutils.strip_path(path) self._path = pathutils.strip_path(path)
self._encoding = storage_.configuration.get("encoding", "stock") self._encoding = storage_.configuration.get("encoding", "stock")
self._skip_broken_item = storage_.configuration.get("storage", "skip_broken_item")
if filesystem_path is None: if filesystem_path is None:
filesystem_path = pathutils.path_to_filesystem(folder, self.path) filesystem_path = pathutils.path_to_filesystem(folder, self.path)
self._filesystem_path = filesystem_path self._filesystem_path = filesystem_path

View file

@ -1,7 +1,8 @@
# This file is part of Radicale - CalDAV and CardDAV server # This file is part of Radicale - CalDAV and CardDAV server
# Copyright © 2014 Jean-Marc Martins # Copyright © 2014 Jean-Marc Martins
# Copyright © 2012-2017 Guillaume Ayoub # Copyright © 2012-2017 Guillaume Ayoub
# Copyright © 2017-2018 Unrud <unrud@outlook.com> # Copyright © 2017-2022 Unrud <unrud@outlook.com>
# Copyright © 2024-2024 Peter Bieringer <pb@bieringer.de>
# #
# This library is free software: you can redistribute it and/or modify # This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -101,6 +102,10 @@ class CollectionPartGet(CollectionPartCache, CollectionPartLock,
cache_content = self._store_item_cache( cache_content = self._store_item_cache(
href, temp_item, cache_hash) href, temp_item, cache_hash)
except Exception as e: except Exception as e:
if self._skip_broken_item:
logger.warning("Skip broken item %r in %r: %s", href, self.path, e)
return None
else:
raise RuntimeError("Failed to load item %r in %r: %s" % raise RuntimeError("Failed to load item %r in %r: %s" %
(href, self.path, e)) from e (href, self.path, e)) from e
# Clean cache entries once after the data in the file # Clean cache entries once after the data in the file