From 4e58d9fe4ac4af4f1324ece44d0be1b1e950f13e 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. --- CHANGELOG.rst | 1 + docs/config.rst | 17 +++++++++-------- tests/storage/test_http_with_singlefile.py | 7 +++++-- vdirsyncer/storage/http.py | 2 ++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a9fe7276..eb31aaaa 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,7 @@ Version 0.19.3 - Add an option to request vCard v4.0. :gh:`1066` - Require matching ``BEGIN`` and ``END`` lines in vobjects. :gh:`1103` - A Docker environment for Vdirsyncer has been added `Vdirsyncer DOCKERIZED `_. +- Expose ``ignore_uids`` config parameter for :storage:`http`. Version 0.19.2 ============== diff --git a/docs/config.rst b/docs/config.rst index d157be31..41db290c 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 5d29eaea..d522e1aa 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 41d94e83..d66faa38 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