mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-07-13 17:23:56 +01:00
Remove unusued NetworkFailureException.
This commit is contained in:
committed by
Greyson Parrelli
parent
c568f2e9cc
commit
d6316d955f
@@ -9,7 +9,6 @@ import org.signal.core.util.Base64;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.AppCapabilities;
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.JsonJobData;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
@@ -19,12 +18,11 @@ import org.thoughtcrime.securesms.keyvalue.SvrValues;
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork;
|
||||
import org.thoughtcrime.securesms.registration.data.RegistrationRepository;
|
||||
import org.thoughtcrime.securesms.registration.secondary.DeviceNameCipher;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.api.NetworkResultUtil;
|
||||
import org.whispersystems.signalservice.api.account.AccountAttributes;
|
||||
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NetworkFailureException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -134,7 +132,7 @@ public class RefreshAttributesJob extends BaseJob {
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(@NonNull Exception e) {
|
||||
return e instanceof NetworkFailureException;
|
||||
return e instanceof IOException && !(e instanceof NonSuccessfulResponseCodeException);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,8 +13,10 @@ import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.JsonJobData
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.whispersystems.signalservice.api.NetworkResult
|
||||
import org.whispersystems.signalservice.api.archive.ArchiveGetMediaItemsResponse
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NetworkFailureException
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException
|
||||
import java.io.IOException
|
||||
import java.lang.Exception
|
||||
|
||||
/**
|
||||
@@ -63,8 +65,10 @@ class SyncArchivedMediaJob private constructor(
|
||||
attachmentsToDelete += syncPage(archivedItemPage)
|
||||
cursor = archivedItemPage.cursor
|
||||
if (attachmentsToDelete.size >= batchSize) {
|
||||
BackupRepository.deleteAbandonedMediaObjects(attachmentsToDelete)
|
||||
Log.i(TAG, "Deleted ${attachmentsToDelete.size} attachments off CDN")
|
||||
when (val result = BackupRepository.deleteAbandonedMediaObjects(attachmentsToDelete)) {
|
||||
is NetworkResult.Success -> Log.i(TAG, "Deleted ${attachmentsToDelete.size} attachments off CDN")
|
||||
else -> Log.w(TAG, "Failed to delete attachments from CDN", result.getCause())
|
||||
}
|
||||
attachmentsToDelete.clear()
|
||||
}
|
||||
if (attachmentsToDelete.isEmpty()) {
|
||||
@@ -97,7 +101,7 @@ class SyncArchivedMediaJob private constructor(
|
||||
}
|
||||
|
||||
override fun onShouldRetry(e: Exception): Boolean {
|
||||
return e is NetworkFailureException
|
||||
return e is IOException && e !is NonSuccessfulResponseCodeException
|
||||
}
|
||||
|
||||
class Factory : Job.Factory<SyncArchivedMediaJob> {
|
||||
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2014-2016 Open Whisper Systems
|
||||
*
|
||||
* Licensed according to the LICENSE file in this repository.
|
||||
*/
|
||||
package org.whispersystems.signalservice.api.push.exceptions;
|
||||
|
||||
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class EncapsulatedExceptions extends Throwable {
|
||||
|
||||
private final List<UntrustedIdentityException> untrustedIdentityExceptions;
|
||||
private final List<UnregisteredUserException> unregisteredUserExceptions;
|
||||
private final List<NetworkFailureException> networkExceptions;
|
||||
|
||||
public EncapsulatedExceptions(List<UntrustedIdentityException> untrustedIdentities,
|
||||
List<UnregisteredUserException> unregisteredUsers,
|
||||
List<NetworkFailureException> networkExceptions)
|
||||
{
|
||||
this.untrustedIdentityExceptions = untrustedIdentities;
|
||||
this.unregisteredUserExceptions = unregisteredUsers;
|
||||
this.networkExceptions = networkExceptions;
|
||||
}
|
||||
|
||||
public EncapsulatedExceptions(UntrustedIdentityException e) {
|
||||
this.untrustedIdentityExceptions = new LinkedList<>();
|
||||
this.unregisteredUserExceptions = new LinkedList<>();
|
||||
this.networkExceptions = new LinkedList<>();
|
||||
|
||||
this.untrustedIdentityExceptions.add(e);
|
||||
}
|
||||
|
||||
public List<UntrustedIdentityException> getUntrustedIdentityExceptions() {
|
||||
return untrustedIdentityExceptions;
|
||||
}
|
||||
|
||||
public List<UnregisteredUserException> getUnregisteredUserExceptions() {
|
||||
return unregisteredUserExceptions;
|
||||
}
|
||||
|
||||
public List<NetworkFailureException> getNetworkExceptions() {
|
||||
return networkExceptions;
|
||||
}
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2014-2016 Open Whisper Systems
|
||||
*
|
||||
* Licensed according to the LICENSE file in this repository.
|
||||
*/
|
||||
|
||||
package org.whispersystems.signalservice.api.push.exceptions;
|
||||
|
||||
public class NetworkFailureException extends Exception {
|
||||
|
||||
private final String e164number;
|
||||
|
||||
public NetworkFailureException(String e164number, Exception nested) {
|
||||
super(nested);
|
||||
this.e164number = e164number;
|
||||
}
|
||||
|
||||
public String getE164number() {
|
||||
return e164number;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user