From 8f63da6dfe1d1fa54f97661d8399cc45c3b455cb Mon Sep 17 00:00:00 2001 From: euxane Date: Sun, 1 Sep 2024 12:27:13 +0200 Subject: [PATCH] storage/http: expose `ignore_uids` config parameter This allows users to choose whether or not to ignore the UIDs coming from WebCAL providers and instead use the item's content hash. This remains the default behaviour. In my case, my provider was generating stable UIDs but was patching the export date in other fields, resulting in the hash of all events changing at each synchronisation, having the opposite effect. --- AUTHORS.rst | 1 + CHANGELOG.rst | 1 + docs/config.rst | 17 +++++++++-------- tests/storage/test_http_with_singlefile.py | 7 +++++-- vdirsyncer/storage/http.py | 2 ++ 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 564730303..fb24a7107 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -8,6 +8,7 @@ In alphabetical order: - Christian Geier - Clément Mondon - Corey Hinshaw +- Euxane TRAN-GIRARD - Kai Herlemann - Hugo Osvaldo Barrera - Jason Cox diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f0ded6a0e..ad3047360 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,7 @@ Version 0.19.3 - Require matching ``BEGIN`` and ``END`` lines in vobjects. :gh:`1103` - A Docker environment for Vdirsyncer has been added `Vdirsyncer DOCKERIZED `_. - Implement digest auth. :gh:`1137` +- Expose ``ignore_uids`` config parameter for :storage:`http`, :gh:`1135` Version 0.19.2 ============== diff --git a/docs/config.rst b/docs/config.rst index d157be316..41db290c2 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -484,14 +484,7 @@ leads to an error. [storage holidays_remote] type = "http" url = https://example.com/holidays_from_hicksville.ics - - Too many WebCAL providers generate UIDs of all ``VEVENT``-components - on-the-fly, i.e. all UIDs change every time the calendar is downloaded. - This leads many synchronization programs to believe that all events have - been deleted and new ones created, and accordingly causes a lot of - unnecessary uploads and deletions on the other side. Vdirsyncer completely - ignores UIDs coming from :storage:`http` and will replace them with a hash - of the normalized item content. + #ignore_uids = true :param url: URL to the ``.ics`` file. :param username: Username for authentication. @@ -508,3 +501,11 @@ leads to an error. :param auth_cert: Optional. Either a path to a certificate with a client certificate and the key or a list of paths to the files with them. :param useragent: Default ``vdirsyncer``. + :param ignore_uids: Ignore UIDs coming from :storage:`http` and replace + them with a hash of the normalized item content. + Too many WebCAL providers generate UIDs of all ``VEVENT``-components + on-the-fly, i.e. all UIDs change every time the calendar is downloaded. + This leads many synchronization programs to believe that all events + have been deleted and new ones created, and accordingly causes a lot of + unnecessary uploads and deletions on the other side. + Default: ``true``. diff --git a/tests/storage/test_http_with_singlefile.py b/tests/storage/test_http_with_singlefile.py index 5d29eaeaa..d522e1aa2 100644 --- a/tests/storage/test_http_with_singlefile.py +++ b/tests/storage/test_http_with_singlefile.py @@ -26,8 +26,11 @@ def __init__(self, url, path, *, connector, **kwargs): super().__init__(**kwargs) self.url = url self.path = path - self._reader = vdirsyncer.storage.http.HttpStorage(url=url, connector=connector) - self._reader._ignore_uids = False + self._reader = vdirsyncer.storage.http.HttpStorage( + url=url, + connector=connector, + ignore_uids=False, + ) self._writer = SingleFileStorage(path=path) async def list(self, *a, **kw): diff --git a/vdirsyncer/storage/http.py b/vdirsyncer/storage/http.py index 41d94e830..d66faa38d 100644 --- a/vdirsyncer/storage/http.py +++ b/vdirsyncer/storage/http.py @@ -32,6 +32,7 @@ def __init__( verify=None, auth=None, useragent=USERAGENT, + ignore_uids=True, verify_fingerprint=None, auth_cert=None, *, @@ -54,6 +55,7 @@ def __init__( self.username, self.password = username, password self.useragent = useragent + self._ignore_uids = ignore_uids assert connector is not None self.connector = connector