Change summary
  src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java              | 5 
src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java | 4 
2 files changed, 7 insertions(+), 2 deletions(-)
  Detailed changes
  
  
    
    @@ -195,9 +195,12 @@ public class HttpDownloadConnection implements Transferable {
         try {
             mXmppConnectionService.getFileBackend().setupRelativeFilePath(message, new FileInputStream(tmp), extension);
             file = mXmppConnectionService.getFileBackend().getFile(message);
-            tmp.renameTo(file);
+            boolean didRename = tmp.renameTo(file);
+            if (!didRename) throw new IOException("rename failed");
         } catch (final IOException e) {
+            Log.w(Config.LOGTAG, "Failed to rename downloaded file: " + e);
             file = tmp;
+            message.setRelativeFilePath(file.getAbsolutePath());
         }
         message.setTransferable(null);
         mXmppConnectionService.updateMessage(message);
  
  
  
    
    @@ -133,9 +133,11 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
                 try {
                     xmppConnectionService.getFileBackend().setupRelativeFilePath(message, new FileInputStream(file), extension);
                     finalFile = xmppConnectionService.getFileBackend().getFile(message);
-                    file.renameTo(finalFile);
+                    boolean didRename = file.renameTo(finalFile);
+                    if (!didRename) throw new IOException("rename failed");
                 } catch (final IOException e) {
                     finalFile = file;
+                    message.setRelativeFilePath(finalFile.getAbsolutePath());
                 }
 
                 xmppConnectionService.getFileBackend().updateFileParams(message, null, false);