mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-28 11:29:01 +03:00
Don't overwrite DB Status LOCAL_CREATED with LOCAL_EDITED
To prevent errors on synchronization (create -> edit -> sync)
This commit is contained in:
parent
37df7dd93c
commit
eb6e2b0d74
1 changed files with 18 additions and 1 deletions
|
@ -226,9 +226,26 @@ public class NoteSQLiteOpenHelper extends SQLiteOpenHelper {
|
|||
@SuppressWarnings("UnusedReturnValue")
|
||||
public int updateNoteAndSync(Note note) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
DBStatus newStatus = DBStatus.LOCAL_EDITED;
|
||||
Cursor cursor =
|
||||
db.query(table_notes,
|
||||
columns,
|
||||
key_id + " = ? AND " + key_status + " != ?",
|
||||
new String[]{String.valueOf(note.getId()), DBStatus.LOCAL_DELETED.getTitle()},
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
if (cursor != null) {
|
||||
cursor.moveToFirst();
|
||||
if (DBStatus.valueOf(cursor.getString(1)) == DBStatus.LOCAL_CREATED) {
|
||||
newStatus = DBStatus.LOCAL_CREATED;
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(key_id, note.getId());
|
||||
values.put(key_status, DBStatus.LOCAL_EDITED.getTitle());
|
||||
values.put(key_status, newStatus.getTitle());
|
||||
values.put(key_title, note.getTitle());
|
||||
values.put(key_modified, note.getModified(DATE_FORMAT));
|
||||
values.put(key_content, note.getContent());
|
||||
|
|
Loading…
Reference in a new issue