mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Reset upload progress if attachment upload is interrupted.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user