diff --git a/gradle.properties b/gradle.properties index 0b3aa29..f8dc0d2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=com.mineinabyss -version=2.0.0-alpha.9 +version=2.0.0-alpha.10 idofrontVersion=0.22.3 diff --git a/src/main/kotlin/com/mineinabyss/launchy/logic/Launcher.kt b/src/main/kotlin/com/mineinabyss/launchy/logic/Launcher.kt index 9e8c33e..cae9474 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/logic/Launcher.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/logic/Launcher.kt @@ -89,7 +89,7 @@ object Launcher { minecraftDir: Path, onStartDownload: (String) -> Unit = {}, onFinishDownload: (String) -> Unit = {} - ): Job = AppDispatchers.IO.launch { + ): Job { val downloadJob = Job() minecraftDir.createParentDirectories() val dir = MinecraftDirectory(minecraftDir.toFile()) @@ -98,25 +98,28 @@ object Launcher { modLoaders.fabricLoader != null -> fabricDownloader() else -> vanillaDownloader() } - val callback = object : CallbackAdapter() { - override fun done(result: Version) { - onFinishDownload("${result.type} $result") - downloader.shutdown() - downloadJob.complete() - } + AppDispatchers.IO.launch { + val callback = object : CallbackAdapter() { + override fun done(result: Version) { + onFinishDownload("${result.type} $result") + downloader.shutdown() + downloadJob.complete() + } - override fun failed(e: Throwable) { - e.printStackTrace() - downloader.shutdown() - downloadJob.complete() - } + override fun failed(e: Throwable) { + e.printStackTrace() + downloader.shutdown() + downloadJob.complete() + } - override fun taskStart(task: DownloadTask?): DownloadCallback? { - onStartDownload(modLoaders.fullVersionName) - return null + override fun taskStart(task: DownloadTask?): DownloadCallback? { + onStartDownload(modLoaders.fullVersionName) + return null + } } + downloader.downloadIncrementally(dir, modLoaders.fullVersionName, callback) } - downloader.downloadIncrementally(dir, modLoaders.fullVersionName, callback) + return downloadJob } diff --git a/src/main/kotlin/com/mineinabyss/launchy/logic/ModDownloader.kt b/src/main/kotlin/com/mineinabyss/launchy/logic/ModDownloader.kt index 0cbb3d6..4218762 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/logic/ModDownloader.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/logic/ModDownloader.kt @@ -146,6 +146,11 @@ object ModDownloader { userAgreedDeps = modpack.modLoaders ensureDependenciesReady(state) copyOverrides(state) + + queued.deletions.forEach { + queued.modDownloadInfo.remove(it.modId) + } + val downloads = queued.needsInstall.map { mod -> async(AppDispatchers.IOContext) { mod to download(mod, ignoreCachedCheck) diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/newinstance/NewInstance.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/newinstance/NewInstance.kt index d4d7861..ca4f595 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/newinstance/NewInstance.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/home/newinstance/NewInstance.kt @@ -29,7 +29,6 @@ import com.mineinabyss.launchy.ui.elements.ComfyWidth import com.mineinabyss.launchy.ui.screens.Screen import com.mineinabyss.launchy.ui.screens.home.InstanceCard import com.mineinabyss.launchy.ui.screens.screen -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlin.collections.set import kotlin.io.path.deleteIfExists @@ -99,10 +98,13 @@ fun ImportTab(visible: Boolean, onGetInstance: (GameInstanceConfig) -> Unit = {} val taskKey = "importCloudInstance" val downloadPath = Dirs.tmpCloudInstance(urlText) downloadPath.deleteIfExists() - AppDispatchers.IO.launch(Dispatchers.IO) { + AppDispatchers.IO.launch { state.inProgressTasks[taskKey] = InProgressTask("Importing cloud instance") - val cloudInstance = - Downloader.download(urlText, downloadPath, skipDownloadIfCached = false).mapCatching { + val cloudInstance = Downloader.download( + urlText, + downloadPath, + skipDownloadIfCached = false + ).mapCatching { GameInstanceConfig.read(downloadPath) .showDialogOnError("Failed to read cloud instance") .getOrThrow()