aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/persistance/db/access/MessageDatabaseAccess.java22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/persistance/db/access/MessageDatabaseAccess.java b/src/main/java/de/thedevstack/conversationsplus/persistance/db/access/MessageDatabaseAccess.java
index 2fc4481d..43ae6ebb 100644
--- a/src/main/java/de/thedevstack/conversationsplus/persistance/db/access/MessageDatabaseAccess.java
+++ b/src/main/java/de/thedevstack/conversationsplus/persistance/db/access/MessageDatabaseAccess.java
@@ -104,7 +104,18 @@ public class MessageDatabaseAccess extends AbstractDatabaseAccess {
message.setTreatAsDownloadable(treatAsDownloadable);
- if (message.hasFileAttached()) {
+ String status = CursorHelper.getString(cursor, COLUMN_NAME_MSG_PARAMS_FILE_STATUS);
+ FileStatus fileStatus = FileStatus.UNDEFINED;
+ if (null != status && !status.isEmpty()) {
+ try {
+ fileStatus = FileStatus.valueOf(status);
+ } catch (IllegalArgumentException e) {
+ // Should only happen if the database is corrupted, but to be on the save side catch it here
+ Logging.e("db.msg", "Unknown FileStatus for fileParams.fileStatus found: '" + status + "'");
+ }
+ }
+ String url = CursorHelper.getString(cursor, COLUMN_NAME_MSG_PARAMS_FILE_URL);
+ if (message.hasFileAttached() || null != url) {
FileParams fileParams = new FileParams(message.getBody());
String fileType = CursorHelper.getString(cursor, COLUMN_NAME_MSG_PARAMS_FILE_TYPE);
fileParams.setMimeType(fileType);
@@ -114,7 +125,6 @@ public class MessageDatabaseAccess extends AbstractDatabaseAccess {
fileParams.setOriginalFilename(originalFilename);
String path = CursorHelper.getString(cursor, COLUMN_NAME_MSG_PARAMS_FILE_PATH);
fileParams.setPath(path);
- String url = CursorHelper.getString(cursor, COLUMN_NAME_MSG_PARAMS_FILE_URL);
fileParams.setUrl(url);
String iv = CursorHelper.getString(cursor, COLUMN_NAME_MSG_PARAMS_FILE_IV);
if (null != iv && !iv.isEmpty()) {
@@ -130,15 +140,7 @@ public class MessageDatabaseAccess extends AbstractDatabaseAccess {
fileParams.setHeight(imageHeight);
int imageWidth = CursorHelper.getInt(cursor, COLUMN_NAME_MSG_PARAMS_FILE_WIDTH);
fileParams.setWidth(imageWidth);
- String status = CursorHelper.getString(cursor, COLUMN_NAME_MSG_PARAMS_FILE_STATUS);
if (null != status && !status.isEmpty()) {
- FileStatus fileStatus = FileStatus.UNDEFINED;
- try {
- fileStatus = FileStatus.valueOf(status);
- } catch (IllegalArgumentException e) {
- // Should only happen if the database is corrupted, but to be on the save side catch it here
- Logging.e("db.msg", "Unknown FileStatus for fileParams.fileStatus found: '" + status + "'");
- }
fileParams.setFileStatus(fileStatus);
}
message.setFileParams(fileParams);