Loosen up validation for vdirs

Otherwise we would have breakage for vdirs where the href is not uid +
fileext (which is the case with old watdo versions)
This commit is contained in:
Markus Unterwaditzer 2014-03-10 18:29:09 +01:00
parent 221968b787
commit 0fd07ec9de

View file

@ -11,6 +11,8 @@ import os
from vdirsyncer.storage.base import Storage, Item
import vdirsyncer.exceptions as exceptions
from vdirsyncer.utils import expand_path
import vdirsyncer.log as log
logger = log.get('storage.filesystem')
class FilesystemStorage(Storage):
@ -65,7 +67,8 @@ class FilesystemStorage(Storage):
def update(self, href, obj, etag):
fpath = self._get_filepath(href)
if href != self._get_href(obj.uid):
raise exceptions.NotFoundError(obj.uid)
logger.warning('href != uid + fileext: href={}; uid={}'
.format(href, obj.uid))
if not os.path.exists(fpath):
raise exceptions.NotFoundError(obj.uid)
actual_etag = os.path.getmtime(fpath)