Fix null pointer when task is missing

pull/1143/head
Alex Baker 4 years ago
parent 9ffc789b0e
commit 5da49d9ee1

@ -303,17 +303,13 @@ class OpenTasksSynchronizer @Inject constructor(
if (!it.moveToFirst()) { if (!it.moveToFirst()) {
return return
} }
val task: Task val task = existing?.task
val caldavTask: CaldavTask ?.let { task -> taskDao.fetch(task) }
if (existing == null) { ?: taskCreator
task = taskCreator.createWithValues("") .createWithValues("")
taskDao.createNew(task) .apply { taskDao.createNew(this) }
val remoteId = it.getString(Tasks._UID) val caldavTask = existing
caldavTask = CaldavTask(task.id, calendar.uuid, remoteId, syncId) ?: CaldavTask(task.id, calendar.uuid, it.getString(Tasks._UID), syncId)
} else {
task = taskDao.fetch(existing.task)!!
caldavTask = existing
}
task.title = it.getString(Tasks.TITLE) task.title = it.getString(Tasks.TITLE)
task.priority = CaldavConverter.fromRemote(it.getInt(Tasks.PRIORITY)) task.priority = CaldavConverter.fromRemote(it.getInt(Tasks.PRIORITY))
task.completionDate = it.getLong(Tasks.COMPLETED) task.completionDate = it.getLong(Tasks.COMPLETED)

Loading…
Cancel
Save