calcurse-caldav: Avoid corrupting the sync DB

When importing an iCal event via calcurse fails (i.e. does not return a
single object hash), do not write anything to the synchronization
database instead of blindly appending the entry, thereby potentially
corrupting the database.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lukas Fleischer 2017-11-17 06:24:49 +01:00
parent 16e7aecd29
commit edc44d613b

View File

@ -431,8 +431,15 @@ def pull_objects(hrefs_missing, hrefs_modified, conn, syncdb, etagdict):
continue
objhash = calcurse_import(cdata)
# TODO: Add support for importing multiple events at once, see GitHub
# issue #20 for details.
if re.match(r'[0-ga-f]+$', objhash):
syncdb_add(syncdb, href, etag, objhash)
added += 1
else:
print("Failed to import object: {} ({})".format(etag, href),
file=sys.stderr)
return added