Skip to content

Commit

Permalink
delete old library before extracting
Browse files Browse the repository at this point in the history
  • Loading branch information
qimiko committed Jan 6, 2024
1 parent bd6cf43 commit 49dcb32
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
26 changes: 17 additions & 9 deletions app/src/main/java/com/geode/launcher/utils/DownloadUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/java/com/geode/launcher/utils/ReleaseManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 49dcb32

Please sign in to comment.