Skip to content

Commit

Permalink
storage/http: expose ignore_uids config parameter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pacien committed Sep 1, 2024
1 parent 8550475 commit 4e58d9f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/Bleala/Vdirsyncer-DOCKERIZED>`_.
- Expose ``ignore_uids`` config parameter for :storage:`http`.

Version 0.19.2
==============
Expand Down
17 changes: 9 additions & 8 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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``.
7 changes: 5 additions & 2 deletions tests/storage/test_http_with_singlefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions vdirsyncer/storage/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(
verify=None,
auth=None,
useragent=USERAGENT,
ignore_uids=True,
verify_fingerprint=None,
auth_cert=None,
*,
Expand All @@ -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

Expand Down

0 comments on commit 4e58d9f

Please sign in to comment.