Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to skip objects the remote fails to provide #866

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions vdirsyncer/storage/dav.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def init_and_remaining_args(cls, **kwargs):

def __init__(self, url, username='', password='', verify=True, auth=None,
useragent=USERAGENT, verify_fingerprint=None,
auth_cert=None):
auth_cert=None, ignore_missing_href=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to somehow pass this data to this function?

I guess it should be a setting for the storage, is that what you had a mind?

If so, that would be an acceptable change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @WhyNotHugo, yes correct. I have this in my config:
[storage example]
...
ignore_missing_href = true

I'm not sure about the name of the option. It probably won't be obvious what it does for someone that hasn't read the code

self._settings = {
'cert': prepare_client_cert(auth_cert),
'auth': prepare_auth(auth, username, password)
Expand All @@ -376,6 +376,7 @@ def __init__(self, url, username='', password='', verify=True, auth=None,

self.useragent = useragent
self.url = url.rstrip('/') + '/'
self.ignore_missing_href = ignore_missing_href

self._session = requests.session()

Expand Down Expand Up @@ -504,7 +505,8 @@ def get_multi(self, hrefs):
else:
rv.append((href, Item(raw), etag))
for href in hrefs_left:
raise exceptions.NotFoundError(href)
if not self.session.ignore_missing_href:
raise exceptions.NotFoundError(href)
return rv

def _put(self, href, item, etag):
Expand Down