From ac50b367b7607235d2dd8ba87eeec969787c9fe2 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 14 Oct 2017 02:38:05 +0200 Subject: [PATCH] don't share video twice after transcoding exception. fixes #2652 --- .../services/AttachFileToConversationRunnable.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java index 9d9f200e3..13c3f3e26 100644 --- a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java +++ b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java @@ -84,13 +84,18 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod final int runtime = mXmppConnectionService.getFileBackend().getMediaRuntime(uri); MediaFormatStrategy formatStrategy = runtime >= 8000 ? MediaFormatStrategyPresets.createExportPreset960x540Strategy() : MediaFormatStrategyPresets.createAndroid720pStrategy(); 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 future = MediaTranscoder.getInstance().transcodeVideo(fileDescriptor, file.getAbsolutePath(), formatStrategy, 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 +137,7 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod if (isVideoMessage) { try { processAsVideo(); - } catch (Throwable e) { + } catch (FileNotFoundException e) { processAsFile(); } } else {