Skip to content

Commit

Permalink
Revert : Uneccesary try-catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
neeldoshii committed Mar 17, 2024
1 parent 56af6f7 commit 6b56838
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/MediaService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,17 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

suspend fun AnkiActivity.checkMedia(): MediaCheckResult? {
return try {
withContext(Dispatchers.IO) {
if (ScopedStorageService.mediaMigrationIsInProgress(this@checkMedia)) {
withContext(Dispatchers.Main) {
showSnackbar(
R.string.functionality_disabled_during_storage_migration,
Snackbar.LENGTH_SHORT
)
}
null
} else {
CollectionManager.withCol { media.check() }
return withContext(Dispatchers.IO) {
if (ScopedStorageService.mediaMigrationIsInProgress(this@checkMedia)) {
withContext(Dispatchers.Main) {
showSnackbar(
R.string.functionality_disabled_during_storage_migration,
Snackbar.LENGTH_SHORT
)
}
null
} else {
CollectionManager.withCol { media.check() }
}
} finally {
this@checkMedia.hideProgressBar()
}
}

0 comments on commit 6b56838

Please sign in to comment.