From 6e185319201636c006a1d54768ed3d5982a70f55 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Mon, 24 Jul 2017 14:39:44 +0200 Subject: [PATCH] preserve last update time and seen on keyserver value during consolidate --- .../keychain/provider/KeyWritableRepository.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java index 7004a367f..abea30df4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java @@ -1185,19 +1185,29 @@ public class KeyWritableRepository extends KeyRepository { ArrayList updatedKeysValues = new ArrayList<>(); final int INDEX_MASTER_KEY_ID = 0; final int INDEX_LAST_UPDATED = 1; + final int INDEX_SEEN_ON_KEYSERVERS = 2; Cursor lastUpdatedCursor = mContentResolver.query( UpdatedKeys.CONTENT_URI, new String[]{ UpdatedKeys.MASTER_KEY_ID, - UpdatedKeys.LAST_UPDATED + UpdatedKeys.LAST_UPDATED, + UpdatedKeys.SEEN_ON_KEYSERVERS }, null, null, null); while (lastUpdatedCursor.moveToNext()) { ContentValues values = new ContentValues(); values.put(UpdatedKeys.MASTER_KEY_ID, lastUpdatedCursor.getLong(INDEX_MASTER_KEY_ID)); - values.put(UpdatedKeys.LAST_UPDATED, - lastUpdatedCursor.getLong(INDEX_LAST_UPDATED)); + if (!lastUpdatedCursor.isNull(INDEX_LAST_UPDATED)) { + values.put(UpdatedKeys.LAST_UPDATED, lastUpdatedCursor.getLong(INDEX_LAST_UPDATED)); + } else { + values.putNull(UpdatedKeys.LAST_UPDATED); + } + if (!lastUpdatedCursor.isNull(INDEX_SEEN_ON_KEYSERVERS)) { + values.put(UpdatedKeys.SEEN_ON_KEYSERVERS, lastUpdatedCursor.getInt(INDEX_SEEN_ON_KEYSERVERS)); + } else { + values.putNull(UpdatedKeys.SEEN_ON_KEYSERVERS); + } updatedKeysValues.add(values); } lastUpdatedCursor.close();