mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +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.SignalServiceAttachment
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream
|
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResumableUploadResponseCodeException
|
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResumableUploadResponseCodeException
|
||||||
|
import org.whispersystems.signalservice.api.push.exceptions.ResumeLocationInvalidException
|
||||||
import org.whispersystems.signalservice.internal.crypto.PaddingInputStream
|
import org.whispersystems.signalservice.internal.crypto.PaddingInputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.Optional
|
import java.util.Optional
|
||||||
@@ -167,6 +168,11 @@ class AttachmentUploadJob private constructor(
|
|||||||
uploadSpec = null
|
uploadSpec = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw e
|
||||||
|
} catch (e: ResumeLocationInvalidException) {
|
||||||
|
Log.w(TAG, "Resume location invalid. Clearing upload spec.", e)
|
||||||
|
uploadSpec = null
|
||||||
|
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2027,11 +2027,9 @@ public class PushServiceSocket {
|
|||||||
|
|
||||||
try (Response response = call.execute()) {
|
try (Response response = call.execute()) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
offset = Long.parseLong(response.header("Upload-Offset"));
|
offset = Long.parseLong(Objects.requireNonNull(response.header("Upload-Offset")));
|
||||||
} else if (response.code() >= 400 || response.code() < 500) {
|
|
||||||
throw new ResumeLocationInvalidException("Response: " + response);
|
|
||||||
} else {
|
} else {
|
||||||
throw new NonSuccessfulResumableUploadResponseCodeException(response.code(), "Response: " + response);
|
throw new ResumeLocationInvalidException("Response: " + response);
|
||||||
}
|
}
|
||||||
} catch (PushNetworkException | NonSuccessfulResponseCodeException e) {
|
} catch (PushNetworkException | NonSuccessfulResponseCodeException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
Reference in New Issue
Block a user