aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2018-03-05 19:48:11 +0100
committersteckbrief <steckbrief@chefmail.de>2018-03-05 19:48:11 +0100
commit1be60ce8c8426b357cf9e4b6e36e09e3a3a9557d (patch)
tree7c54285909fd699706ba0abd0b1a303abd081e2c /src
parent144a82ada2391d65063866063950560af29758d0 (diff)
fixes problems while loading FileParams from db
Diffstat (limited to 'src')
-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);