mirror of
https://github.com/etesync/android
synced 2025-01-11 00:01:12 +00:00
Fix crash when deleting an item before it was ever uploaded.
This commit is contained in:
parent
18c784692f
commit
17e7085aa4
@ -644,25 +644,7 @@ constructor(protected val context: Context, protected val account: Account, prot
|
|||||||
item.meta = meta
|
item.meta = meta
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createPushItems(): List<Item> {
|
private fun prepareLocalItemForUpload(colUid: String, local: T): 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) {
|
|
||||||
val cacheItem = if (local.fileName != null) etebaseLocalCache.itemGet(itemMgr, colUid, local.fileName!!) else null
|
val cacheItem = if (local.fileName != null) etebaseLocalCache.itemGet(itemMgr, colUid, local.fileName!!) else null
|
||||||
val item: Item
|
val item: Item
|
||||||
if (cacheItem != null) {
|
if (cacheItem != null) {
|
||||||
@ -692,6 +674,30 @@ constructor(protected val context: Context, protected val account: Account, prot
|
|||||||
throw e
|
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)
|
ret.add(item)
|
||||||
|
|
||||||
if (ret.size == MAX_PUSH) {
|
if (ret.size == MAX_PUSH) {
|
||||||
|
Loading…
Reference in New Issue
Block a user