fix: excess scope and redundancy

This commit is contained in:
TwistedUmbrellaX 2024-03-17 22:04:21 -04:00
parent 12a5b602e9
commit 89fe3b82a3

View file

@ -355,15 +355,13 @@ class AnimeDownloaderService : Service() {
return false return false
} }
@OptIn(DelicateCoroutinesApi::class)
private fun saveMediaInfo(task: AnimeDownloadTask) { private fun saveMediaInfo(task: AnimeDownloadTask) {
GlobalScope.launch(Dispatchers.IO) { CoroutineScope(Dispatchers.IO).launch {
val directory = File( val directory = File(
getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
"${DownloadsManager.animeLocation}/${task.title}" "${DownloadsManager.animeLocation}/${task.title}"
) )
val episodeDirectory = File(directory, task.episode) val episodeDirectory = File(directory, task.episode)
if (!directory.exists()) directory.mkdirs()
if (!episodeDirectory.exists()) episodeDirectory.mkdirs() if (!episodeDirectory.exists()) episodeDirectory.mkdirs()
val file = File(directory, "media.json") val file = File(directory, "media.json")