replace MainScope with coroutineScope for database operations

This commit is contained in:
Rohit Verma 2024-10-26 23:01:45 +05:30
parent 249ed1c8dc
commit 61d5010900
2 changed files with 4 additions and 4 deletions

View file

@ -17,7 +17,7 @@ import fr.free.nrw.commons.utils.CustomSelectorUtils
import fr.free.nrw.commons.utils.CustomSelectorUtils.Companion.checkWhetherFileExistsOnCommonsUsingSHA1
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.util.Calendar
import java.util.concurrent.TimeUnit
@ -65,7 +65,7 @@ class ImageLoader
/**
* Coroutine Scope.
*/
private val scope: CoroutineScope = MainScope()
private val scope: CoroutineScope = CoroutineScope(Dispatchers.IO)
/**
* Query image and setUp the view.

View file

@ -41,8 +41,8 @@ import fr.free.nrw.commons.upload.UploadProgressActivity
import fr.free.nrw.commons.upload.UploadResult
import fr.free.nrw.commons.wikidata.WikidataEditService
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import timber.log.Timber
@ -534,7 +534,7 @@ class UploadWorker(
contribution.contentUri?.let {
val imageSha1 = contribution.imageSHA1.toString()
val modifiedSha1 = fileUtilsWrapper.getSHA1(fileUtilsWrapper.getFileInputStream(contribution.localUri?.path))
MainScope().launch {
CoroutineScope(Dispatchers.IO).launch {
uploadedStatusDao.insertUploaded(
UploadedStatus(
imageSha1,