Fix avatar removal.
This commit is contained in:
parent
b9a10653f1
commit
0484047b4e
1 changed files with 12 additions and 5 deletions
|
@ -6,18 +6,18 @@ import androidx.annotation.NonNull;
|
|||
import android.text.TextUtils;
|
||||
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -90,7 +90,7 @@ public class RetrieveProfileAvatarJob extends BaseJob implements InjectableType
|
|||
}
|
||||
|
||||
if (TextUtils.isEmpty(profileAvatar)) {
|
||||
Log.w(TAG, "Removing profile avatar for: " + recipient.getAddress().serialize());
|
||||
Log.w(TAG, "Removing profile avatar (no url) for: " + recipient.getAddress().serialize());
|
||||
AvatarHelper.delete(context, recipient.getAddress());
|
||||
database.setProfileAvatar(recipient, profileAvatar);
|
||||
return;
|
||||
|
@ -104,6 +104,13 @@ public class RetrieveProfileAvatarJob extends BaseJob implements InjectableType
|
|||
|
||||
Util.copy(avatarStream, new FileOutputStream(decryptDestination));
|
||||
decryptDestination.renameTo(AvatarHelper.getAvatarFile(context, recipient.getAddress()));
|
||||
} catch (PushNetworkException e) {
|
||||
if (e.getCause() instanceof NonSuccessfulResponseCodeException) {
|
||||
Log.w(TAG, "Removing profile avatar (no image available) for: " + recipient.getAddress().serialize());
|
||||
AvatarHelper.delete(context, recipient.getAddress());
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
} finally {
|
||||
if (downloadDestination != null) downloadDestination.delete();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue