aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-10-15 19:27:15 +0200
committerChristian Schneppe <christian@pix-art.de>2017-10-15 19:27:15 +0200
commitb071ff61d8de6ab00ae04fd4adfc795b5725447e (patch)
tree4fd970c5d2a3642322cd5908055efc127a33f027 /src/main/java/de/pixart/messenger
parent9654befc01aa92ace944815a7b2ad16713d0a70f (diff)
rework fix for duplicate file messages
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java b/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java
index f9c67cb46..2df3ab86c 100644
--- a/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java
+++ b/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java
@@ -13,6 +13,7 @@ import java.io.FileNotFoundException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import de.pixart.messenger.Config;
@@ -84,13 +85,18 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod
final DownloadableFile file = mXmppConnectionService.getFileBackend().getFile(message);
final int runtime = mXmppConnectionService.getFileBackend().getMediaRuntime(uri);
file.getParentFile().mkdirs();
- ParcelFileDescriptor parcelFileDescriptor = mXmppConnectionService.getContentResolver().openFileDescriptor(uri, "r");
+ final ParcelFileDescriptor parcelFileDescriptor = mXmppConnectionService.getContentResolver().openFileDescriptor(uri, "r");
+ if (parcelFileDescriptor == null) {
+ throw new FileNotFoundException("Parcel File Descriptor was null");
+ }
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
Future<Void> future = MediaTranscoder.getInstance().transcodeVideo(fileDescriptor, file.getAbsolutePath(), MediaFormatStrategyPresets.createAndroidStandardStrategy(mXmppConnectionService.getCompressVideoBitratePreference(), mXmppConnectionService.getCompressVideoResolutionPreference()), this);
try {
future.get();
- } catch (Exception e) {
+ } catch (InterruptedException e) {
throw new AssertionError(e);
+ } catch (ExecutionException e) {
+ Log.d(Config.LOGTAG, "ignoring execution exception. Should get handled by onTranscodeFiled() instead", e);
}
}
@@ -132,7 +138,8 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod
if (isVideoMessage) {
try {
processAsVideo();
- } catch (Throwable e) {
+ } catch (FileNotFoundException e) {
+ processAsFile();
e.printStackTrace();
}
} else {