Fix error handling for resumable uploads to cdn3.
This commit is contained in:
parent
220d3877a2
commit
7402959ac6
2 changed files with 8 additions and 4 deletions
|
@ -32,6 +32,7 @@ import org.whispersystems.signalservice.api.crypto.AttachmentCipherStreamUtil
|
|||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResumableUploadResponseCodeException
|
||||
import org.whispersystems.signalservice.api.push.exceptions.ResumeLocationInvalidException
|
||||
import org.whispersystems.signalservice.internal.crypto.PaddingInputStream
|
||||
import java.io.IOException
|
||||
import java.util.Optional
|
||||
|
@ -167,6 +168,11 @@ class AttachmentUploadJob private constructor(
|
|||
uploadSpec = null
|
||||
}
|
||||
|
||||
throw e
|
||||
} catch (e: ResumeLocationInvalidException) {
|
||||
Log.w(TAG, "Resume location invalid. Clearing upload spec.", e)
|
||||
uploadSpec = null
|
||||
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2027,11 +2027,9 @@ public class PushServiceSocket {
|
|||
|
||||
try (Response response = call.execute()) {
|
||||
if (response.isSuccessful()) {
|
||||
offset = Long.parseLong(response.header("Upload-Offset"));
|
||||
} else if (response.code() >= 400 || response.code() < 500) {
|
||||
throw new ResumeLocationInvalidException("Response: " + response);
|
||||
offset = Long.parseLong(Objects.requireNonNull(response.header("Upload-Offset")));
|
||||
} else {
|
||||
throw new NonSuccessfulResumableUploadResponseCodeException(response.code(), "Response: " + response);
|
||||
throw new ResumeLocationInvalidException("Response: " + response);
|
||||
}
|
||||
} catch (PushNetworkException | NonSuccessfulResponseCodeException e) {
|
||||
throw e;
|
||||
|
|
Loading…
Add table
Reference in a new issue