aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/siacs/conversations/persistance/FileBackend.java')
-rw-r--r--src/main/java/eu/siacs/conversations/persistance/FileBackend.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
index edbcd26e..349e18c7 100644
--- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
+++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
@@ -61,22 +61,26 @@ public class FileBackend {
final boolean encrypted = !decrypted
&& (message.getEncryption() == Message.ENCRYPTION_PGP
|| message.getEncryption() == Message.ENCRYPTION_DECRYPTED);
- if (encrypted) {
- return new DownloadableFile(getConversationsFileDirectory()+message.getUuid()+".pgp");
+ final DownloadableFile file;
+ String path = message.getRelativeFilePath();
+ if (path == null) {
+ path = message.getUuid();
+ }
+ if (path.startsWith("/")) {
+ file = new DownloadableFile(path);
} else {
- String path = message.getRelativeFilePath();
- if (path == null) {
- path = message.getUuid();
- } else if (path.startsWith("/")) {
- return new DownloadableFile(path);
- }
String mime = message.getMimeType();
if (mime != null && mime.startsWith("image")) {
- return new DownloadableFile(getConversationsImageDirectory() + path);
+ file = new DownloadableFile(getConversationsImageDirectory() + path);
} else {
- return new DownloadableFile(getConversationsFileDirectory() + path);
+ file = new DownloadableFile(getConversationsFileDirectory() + path);
}
}
+ if (encrypted) {
+ return new DownloadableFile(getConversationsFileDirectory() + file.getName() + ".pgp");
+ } else {
+ return file;
+ }
}
public static String getConversationsFileDirectory() {