From 2dbcfed3ba339b093c257e9cc68f75c591c08273 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 30 Mar 2017 20:30:57 -0400 Subject: [PATCH] Mark a stored session as unfresh in case of YapDB object cache. // FREEBIE --- src/Storage/AxolotlStore/TSStorageManager+SessionStore.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Storage/AxolotlStore/TSStorageManager+SessionStore.m b/src/Storage/AxolotlStore/TSStorageManager+SessionStore.m index 4a4755918..4fbb680fa 100644 --- a/src/Storage/AxolotlStore/TSStorageManager+SessionStore.m +++ b/src/Storage/AxolotlStore/TSStorageManager+SessionStore.m @@ -46,6 +46,13 @@ } - (void)storeSession:(NSString *)contactIdentifier deviceId:(int)deviceId session:(SessionRecord *)session { + // We need to ensure subsequent usage of this SessionRecord does not consider this session as "fresh". Normally this + // is achieved by marking things as "not fresh" at the point of deserialization - when we fetch a SessionRecord from + // YapDB (initWithCoder:). However, because YapDB has an object cache, rather than fetching/deserializing, it's + // possible we'd get back *this* exact instance of the object (which, at this point, is still potentially "fresh"), + // thus we explicitly mark this instance as "unfresh", any time we save. + [session markAsUnFresh]; + NSMutableDictionary *dictionary = [[self dictionaryForKey:contactIdentifier inCollection:TSStorageManagerSessionStoreCollection] mutableCopy];