From 15fb71337bf18db2306dc2c19ddbee64ad1f2506 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 20 Apr 2017 20:08:16 +0200 Subject: [PATCH] Calendar Sync: Fix inverted logic when comparing hashes from db Also improve debug output --- .../externalevents/CalendarReceiver.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java index 2a30556b..e1c8bbfc 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java @@ -107,19 +107,23 @@ public class CalendarReceiver extends BroadcastReceiver { for (CalendarEvents.CalendarEvent e : eventList) { - eventTable.put(e.getId(), e); + long id = e.getId(); + eventTable.put(id, e); if (!eventState.containsKey(e.getId())) { qb = session.getCalendarSyncStateDao().queryBuilder(); - CalendarSyncState calendarSyncState = qb.where(qb.and(CalendarSyncStateDao.Properties.DeviceId.eq(deviceId), CalendarSyncStateDao.Properties.CalendarEntryId.eq(e.getId()))) + CalendarSyncState calendarSyncState = qb.where(qb.and(CalendarSyncStateDao.Properties.DeviceId.eq(deviceId), CalendarSyncStateDao.Properties.CalendarEntryId.eq(id))) .build().unique(); if (calendarSyncState == null) { - eventState.put(e.getId(), new EventSyncState(e, EventState.NOT_SYNCED)); - } else if (calendarSyncState.getHash() == e.hashCode()) { - eventState.put(e.getId(), new EventSyncState(e, EventState.NEEDS_UPDATE)); + eventState.put(id, new EventSyncState(e, EventState.NOT_SYNCED)); + LOG.info("event id=" + id + " is yet unknown to device id=" + deviceId); + } else if (calendarSyncState.getHash() == e.hashCode()) { + eventState.put(id, new EventSyncState(e, EventState.SYNCED)); + LOG.info("event id=" + id + " is up to date on device id=" + deviceId); } else { - eventState.put(e.getId(), new EventSyncState(e, EventState.SYNCED)); + eventState.put(id, new EventSyncState(e, EventState.NEEDS_UPDATE)); + LOG.info("event id=" + id + " is not up to date on device id=" + deviceId); } } }