CleanupSession: start by releasing the session, then empty the databases

This commit is contained in:
Benoit Marty 2021-10-12 11:57:07 +02:00
parent 73c08e2eeb
commit 4a7e0a5d95

View file

@ -61,6 +61,9 @@ internal class CleanupSession @Inject constructor(
Timber.d("Cleanup: cancel pending works...") Timber.d("Cleanup: cancel pending works...")
workManagerProvider.cancelAllWorks() workManagerProvider.cancelAllWorks()
Timber.d("Cleanup: release session...")
sessionManager.releaseSession(sessionId)
Timber.d("Cleanup: clear session data...") Timber.d("Cleanup: clear session data...")
clearSessionDataTask.execute(Unit) clearSessionDataTask.execute(Unit)
@ -71,9 +74,6 @@ internal class CleanupSession @Inject constructor(
realmKeysUtils.clear(SessionModule.getKeyAlias(userMd5)) realmKeysUtils.clear(SessionModule.getKeyAlias(userMd5))
realmKeysUtils.clear(CryptoModule.getKeyAlias(userMd5)) realmKeysUtils.clear(CryptoModule.getKeyAlias(userMd5))
Timber.d("Cleanup: release session...")
sessionManager.releaseSession(sessionId)
// Wait for all the Realm instance to be released properly. Closing Realm instance is async. // Wait for all the Realm instance to be released properly. Closing Realm instance is async.
// After that we can safely delete the Realm files // After that we can safely delete the Realm files
waitRealmRelease() waitRealmRelease()