Fix image partially shown after message sent.

fork-5.53.8
Lucio Maciel 2021-09-09 11:47:46 -03:00 zatwierdzone przez GitHub
rodzic e9bbb1b9ae
commit fe82c4e487
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -1076,12 +1076,18 @@ public class AttachmentDatabase extends Database {
throws MmsException
{
try {
File tempFile = newFile();
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
DigestInputStream digestInputStream = new DigestInputStream(in, messageDigest);
Pair<byte[], OutputStream> out = ModernEncryptingPartOutputStream.createFor(attachmentSecret, destination, false);
Pair<byte[], OutputStream> out = ModernEncryptingPartOutputStream.createFor(attachmentSecret, tempFile, false);
long length = StreamUtil.copy(digestInputStream, out.second);
String hash = Base64.encodeBytes(digestInputStream.getMessageDigest().digest());
if (!tempFile.renameTo(destination)) {
Log.w(TAG, "Couldn't rename " + tempFile.getPath() + " to " + destination.getPath());
throw new IllegalStateException("Couldn't rename " + tempFile.getPath() + " to " + destination.getPath());
}
SQLiteDatabase database = databaseHelper.getSignalWritableDatabase();
Optional<DataInfo> sharedDataInfo = findDuplicateDataFileInfo(database, hash, attachmentId);
if (sharedDataInfo.isPresent()) {