mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 12:08:34 +00:00
Fix error handling for resumable uploads to cdn3.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user