1
0
mirror of https://github.com/etesync/android synced 2024-12-23 07:08:16 +00:00

Fix crash when deleting an item before it was ever uploaded.

This commit is contained in:
Tom Hacohen 2020-10-18 10:51:47 +03:00
parent 18c784692f
commit 17e7085aa4

View File

@ -644,25 +644,7 @@ constructor(protected val context: Context, protected val account: Account, prot
item.meta = meta
}
private fun createPushItems(): List<Item> {
val ret = LinkedList<Item>()
val colUid = cachedCollection.col.uid
synchronized(etebaseLocalCache) {
for (local in localDeleted!!) {
val item = etebaseLocalCache.itemGet(itemMgr, colUid, local.fileName!!)!!.item
itemUpdateMtime(item)
item.delete()
ret.add(item)
if (ret.size == MAX_PUSH) {
return ret
}
}
}
synchronized(etebaseLocalCache) {
for (local in localDirty) {
private fun prepareLocalItemForUpload(colUid: String, local: T): Item {
val cacheItem = if (local.fileName != null) etebaseLocalCache.itemGet(itemMgr, colUid, local.fileName!!) else null
val item: Item
if (cacheItem != null) {
@ -692,6 +674,30 @@ constructor(protected val context: Context, protected val account: Account, prot
throw e
}
return item
}
private fun createPushItems(): List<Item> {
val ret = LinkedList<Item>()
val colUid = cachedCollection.col.uid
synchronized(etebaseLocalCache) {
for (local in localDeleted!!) {
val item = prepareLocalItemForUpload(colUid, local)
item.delete()
ret.add(item)
if (ret.size == MAX_PUSH) {
return ret
}
}
}
synchronized(etebaseLocalCache) {
for (local in localDirty) {
val item = prepareLocalItemForUpload(colUid, local)
ret.add(item)
if (ret.size == MAX_PUSH) {