aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-10-06 16:18:23 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-10-06 16:18:23 +0200
commit32abc766898a5524c7e945adf64bd97ffb404c2b (patch)
treeacfa659fdba740a30aa171aeb33cc090e85fd323 /src/main/java/eu/siacs
parent1d2a24c9c02dd34b9d3d8758dff9124d72a154a7 (diff)
changed store path for files
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/persistance/FileBackend.java30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
index 474951db..edbcd26e 100644
--- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
+++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
@@ -58,33 +58,23 @@ public class FileBackend {
}
public DownloadableFile getFile(Message message, boolean decrypted) {
- String path = message.getRelativeFilePath();
- String extension;
- if (path != null && !path.isEmpty()) {
- String[] parts = path.split("\\.");
- extension = "."+parts[parts.length - 1];
- } else {
- if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_TEXT) {
- extension = ".webp";
- } else {
- extension = "";
- }
- path = message.getUuid()+extension;
- }
final boolean encrypted = !decrypted
&& (message.getEncryption() == Message.ENCRYPTION_PGP
|| message.getEncryption() == Message.ENCRYPTION_DECRYPTED);
if (encrypted) {
- return new DownloadableFile(getConversationsFileDirectory()+message.getUuid()+extension+".pgp");
+ return new DownloadableFile(getConversationsFileDirectory()+message.getUuid()+".pgp");
} else {
- if (path.startsWith("/")) {
+ 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);
} else {
- if (Arrays.asList(Transferable.VALID_IMAGE_EXTENSIONS).contains(extension)) {
- return new DownloadableFile(getConversationsFileDirectory() + path);
- } else {
- return new DownloadableFile(getConversationsImageDirectory() + path);
- }
+ return new DownloadableFile(getConversationsFileDirectory() + path);
}
}
}