diff --git a/app/src/main/java/com/geode/launcher/utils/DownloadUtils.kt b/app/src/main/java/com/geode/launcher/utils/DownloadUtils.kt index f42703cf..467f3332 100644 --- a/app/src/main/java/com/geode/launcher/utils/DownloadUtils.kt +++ b/app/src/main/java/com/geode/launcher/utils/DownloadUtils.kt @@ -90,16 +90,24 @@ object DownloadUtils { // note to self: ZipInputStreams are a little silly // (runInterruptible allows it to cancel, otherwise it waits for the stream to finish) runInterruptible { - val zip = ZipInputStream(inputStream) - zip.use { - var entry = it.nextEntry - while (entry != null) { - if (entry.name == zipPath) { - it.copyTo(outputStream) - return@use + inputStream.use { + outputStream.use { + // nice indentation + val zip = ZipInputStream(inputStream) + zip.use { + var entry = it.nextEntry + while (entry != null) { + if (entry.name == zipPath) { + it.copyTo(outputStream) + return@use + } + + entry = it.nextEntry + } + + // no matching entries found, throw exception + throw IOException("no file found for $zipPath") } - - entry = it.nextEntry } } } diff --git a/app/src/main/java/com/geode/launcher/utils/ReleaseManager.kt b/app/src/main/java/com/geode/launcher/utils/ReleaseManager.kt index 2b8e4ee9..83e7eab0 100644 --- a/app/src/main/java/com/geode/launcher/utils/ReleaseManager.kt +++ b/app/src/main/java/com/geode/launcher/utils/ReleaseManager.kt @@ -109,6 +109,11 @@ class ReleaseManager private constructor( val geodeName = LaunchUtils.getGeodeFilename() val geodeFile = getGeodeOutputPath(geodeName) + // work around a permission issue from adb push + if (geodeFile.exists()) { + geodeFile.delete() + } + DownloadUtils.extractFileFromZipStream( fileStream, geodeFile.outputStream(), @@ -144,8 +149,8 @@ class ReleaseManager private constructor( // check if an update is needed if (latestVersion <= currentVersion) { - _uiState.value = ReleaseManagerState.Finished() - return + //_uiState.value = ReleaseManagerState.Finished() + //return } performUpdate(release)