Reset upload progress if attachment upload is interrupted.
This commit is contained in:
parent
4354a9ff5e
commit
45833ef24a
2 changed files with 15 additions and 0 deletions
|
@ -529,6 +529,8 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
val existingEvent = mutableMap[attachment]
|
||||
if (existingEvent == null || updateEvent.completed > existingEvent.completed) {
|
||||
mutableMap[attachment] = updateEvent
|
||||
} else if (updateEvent.completed < 0) {
|
||||
mutableMap.remove(attachment)
|
||||
}
|
||||
verboseLog("onEventAsync compression update")
|
||||
return@updateState it.copy(compressionProgress = mutableMap.toMap())
|
||||
|
@ -538,6 +540,8 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
val existingEvent = mutableMap[attachment]
|
||||
if (existingEvent == null || updateEvent.completed > existingEvent.completed) {
|
||||
mutableMap[attachment] = updateEvent
|
||||
} else if (updateEvent.completed < 0) {
|
||||
mutableMap.remove(attachment)
|
||||
}
|
||||
verboseLog("onEventAsync network update")
|
||||
return@updateState it.copy(networkProgress = mutableMap.toMap())
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.R
|
|||
import org.thoughtcrime.securesms.attachments.Attachment
|
||||
import org.thoughtcrime.securesms.attachments.AttachmentId
|
||||
import org.thoughtcrime.securesms.attachments.AttachmentUploadUtil
|
||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment
|
||||
import org.thoughtcrime.securesms.attachments.PointerAttachment
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
|
@ -180,6 +181,8 @@ class AttachmentUploadJob private constructor(
|
|||
Log.i(TAG, "Stream reset during upload, not resetting network yet, last reset: $lastReset")
|
||||
}
|
||||
|
||||
resetProgressListeners(databaseAttachment)
|
||||
|
||||
throw e
|
||||
} catch (e: NonSuccessfulResumableUploadResponseCodeException) {
|
||||
if (e.code == 400) {
|
||||
|
@ -187,11 +190,15 @@ class AttachmentUploadJob private constructor(
|
|||
uploadSpec = null
|
||||
}
|
||||
|
||||
resetProgressListeners(databaseAttachment)
|
||||
|
||||
throw e
|
||||
} catch (e: ResumeLocationInvalidException) {
|
||||
Log.w(TAG, "Resume location invalid. Clearing upload spec.", e)
|
||||
uploadSpec = null
|
||||
|
||||
resetProgressListeners(databaseAttachment)
|
||||
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
@ -204,6 +211,10 @@ class AttachmentUploadJob private constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun resetProgressListeners(attachment: DatabaseAttachment) {
|
||||
EventBus.getDefault().postSticky(PartProgressEvent(attachment, PartProgressEvent.Type.NETWORK, 0, -1))
|
||||
}
|
||||
|
||||
override fun onFailure() {
|
||||
val database = SignalDatabase.attachments
|
||||
val databaseAttachment = database.getAttachment(attachmentId)
|
||||
|
|
Loading…
Add table
Reference in a new issue