mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2024-11-22 20:56:08 -06:00
Add skipping migration when previous attempt failed (#2508)
This commit is contained in:
parent
254719f22f
commit
d799ec7ac9
@ -23,6 +23,7 @@ class WulkanowySdkFactory @Inject constructor(
|
||||
) {
|
||||
|
||||
private val eduOneMutex = Mutex()
|
||||
private val migrationFailedStudentIds = mutableSetOf<Long>()
|
||||
|
||||
private val sdk = Sdk().apply {
|
||||
androidVersion = android.os.Build.VERSION.RELEASE
|
||||
@ -78,14 +79,24 @@ class WulkanowySdkFactory @Inject constructor(
|
||||
private suspend fun checkEduOneAndMigrateIfNecessary(student: Student): Boolean {
|
||||
if (student.isEduOne != null) return student.isEduOne
|
||||
|
||||
if (student.id in migrationFailedStudentIds) {
|
||||
Timber.i("Migration eduOne: skipping because of previous failure")
|
||||
return false
|
||||
}
|
||||
|
||||
eduOneMutex.withLock {
|
||||
if (student.id in migrationFailedStudentIds) {
|
||||
Timber.i("Migration eduOne: skipping because of previous failure")
|
||||
return false
|
||||
}
|
||||
|
||||
val studentFromDatabase = studentDb.loadById(student.id)
|
||||
if (studentFromDatabase?.isEduOne != null) {
|
||||
Timber.d("Migration eduOne: already done")
|
||||
Timber.i("Migration eduOne: already done")
|
||||
return studentFromDatabase.isEduOne
|
||||
}
|
||||
|
||||
Timber.d("Migration eduOne: flag missing. Running migration...")
|
||||
Timber.i("Migration eduOne: flag missing. Running migration...")
|
||||
val initializedSdk = buildSdk(
|
||||
student = student,
|
||||
semester = null,
|
||||
@ -96,7 +107,8 @@ class WulkanowySdkFactory @Inject constructor(
|
||||
.getOrNull()
|
||||
|
||||
if (newCurrentStudent == null) {
|
||||
Timber.d("Migration eduOne: failed, so skipping")
|
||||
Timber.i("Migration eduOne: failed, so skipping")
|
||||
migrationFailedStudentIds.add(student.id)
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,10 @@ class SemesterRepository @Inject constructor(
|
||||
.getSemesters()
|
||||
.mapToEntities(student.studentId)
|
||||
|
||||
if (new.isEmpty()) return Timber.i("Empty semester list!")
|
||||
if (new.isEmpty()) {
|
||||
Timber.i("Empty semester list from SDK!")
|
||||
return
|
||||
}
|
||||
|
||||
val old = semesterDb.loadAll(student)
|
||||
semesterDb.removeOldAndSaveNew(
|
||||
|
Loading…
Reference in New Issue
Block a user