Fix sync sometimes crashing when ran multiple times without reopening the app

This commit is contained in:
NerdNumber9 2018-02-02 12:48:09 -05:00
parent 8f51abfc97
commit b28a2c3bd4

View File

@ -80,12 +80,12 @@ class FavoritesSyncHelper(val context: Context) {
try { try {
//Take wake + wifi locks //Take wake + wifi locks
wakeLock?.release() ignore { wakeLock?.release() }
wakeLock = ignore { wakeLock = ignore {
context.powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, context.powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"ExhFavoritesSyncWakelock") "ExhFavoritesSyncWakelock")
} }
wifiLock?.release() ignore { wifiLock?.release() }
wifiLock = ignore { wifiLock = ignore {
context.wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, context.wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL,
"ExhFavoritesSyncWifi") "ExhFavoritesSyncWifi")
@ -127,8 +127,14 @@ class FavoritesSyncHelper(val context: Context) {
return return
} finally { } finally {
//Release wake + wifi locks //Release wake + wifi locks
ignore { wakeLock?.release() } ignore {
ignore { wifiLock?.release() } wakeLock?.release()
wakeLock = null
}
ignore {
wifiLock?.release()
wifiLock = null
}
} }
status.onNext(FavoritesSyncStatus.Idle()) status.onNext(FavoritesSyncStatus.Idle())