Fix file not being sent (2)

This commit is contained in:
Yohan Simard 2021-01-06 10:50:20 +01:00
parent 5f0d2ea7b1
commit 03f6e63b69
2 changed files with 2 additions and 7 deletions

View file

@ -248,13 +248,7 @@ public class DatabaseController {
// Handle messages containing a file
String filePath = "NULL";
if (message instanceof FileMessage) {
try {
filePath = "'" + ((FileMessage) message).storeFile() + "'";
} catch (IOException e) {
Log.e(getClass().getSimpleName(), "Error while saving the file", e);
errorCallback.onError(e);
return;
}
filePath = "'" + ((FileMessage) message).getPath() + "'";
}
String recipientId = message.getRecipient().id;

View file

@ -66,6 +66,7 @@ public class PeerUser extends User implements Comparable<PeerUser> {
"Sending file message to " + this.getUsername() + " / " + this.getId() + ": " + msg);
try {
final FileMessage message = new FileMessage(CurrentUser.getInstance(), this, new Date(), msg, file.getPath());
message.storeFile();
connection.send(message, () -> history.addMessage(message, errorCallback), errorCallback);
} catch (IOException e) {
Log.e(this.getClass().getSimpleName(), "Could not send message: error while opening file", e);