diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-01-25 23:24:09 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-01-25 23:24:09 +0100 |
commit | b670a7fb91b6a0b8fc2fbbc44688f4ccf66757b7 (patch) | |
tree | 7468823257f567420d037f1210de36bdd9ee9491 /src/main/java | |
parent | 243a78aa32acf3e1b629f0c106780e27a61778af (diff) |
null checks when deleting old files
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java index f17845b75..d4033eef1 100644 --- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java @@ -858,7 +858,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { public List<FilePath> getAllNonDeletedFilePath() { final SQLiteDatabase db = this.getReadableDatabase(); - final Cursor cursor = db.query(Message.TABLENAME, new String[]{Message.UUID, Message.RELATIVE_FILE_PATH}, "type in (1,2) and file_deleted=0", null, null, null, null); + final Cursor cursor = db.query(Message.TABLENAME, new String[]{Message.UUID, Message.RELATIVE_FILE_PATH}, "type in (1,2) and file_deleted=0 and " + Message.RELATIVE_FILE_PATH + " is not null", null, null, null, null); final List<FilePath> list = new ArrayList<>(); while (cursor != null && cursor.moveToNext()) { list.add(new FilePath(cursor.getString(0), cursor.getString(1))); @@ -871,7 +871,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { public List<FilePath> getRelativeFilePaths(String account, Jid jid, int limit) { SQLiteDatabase db = this.getReadableDatabase(); - final String SQL = "select uuid,relativeFilePath from messages where type in (1,2) and file_deleted=0 and conversationUuid=(select uuid from conversations where accountUuid=? and (contactJid=? or contactJid like ?)) order by timeSent desc"; + final String SQL = "select uuid,relativeFilePath from messages where type in (1,2) and file_deleted=0 and " + Message.RELATIVE_FILE_PATH + " is not null and conversationUuid=(select uuid from conversations where accountUuid=? and (contactJid=? or contactJid like ?)) order by timeSent desc"; final String[] args = {account, jid.toEscapedString(), jid.toEscapedString() + "/%"}; Cursor cursor = db.rawQuery(SQL + (limit > 0 ? " limit " + String.valueOf(limit) : ""), args); List<FilePath> filesPaths = new ArrayList<>(); |