From 8fbf52dbcf47facb33bd0815adf2082e884dd665 Mon Sep 17 00:00:00 2001 From: soupslurpr <92235850+soupslurpr@users.noreply.github.com> Date: Fri, 5 Jan 2024 13:06:19 -0800 Subject: [PATCH] Delete temp apk file if it is invalid --- .../soupslurpr/appverifier/ui/VerifyAppViewModel.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/kotlin/dev/soupslurpr/appverifier/ui/VerifyAppViewModel.kt b/app/src/main/kotlin/dev/soupslurpr/appverifier/ui/VerifyAppViewModel.kt index a45be02a..7563c607 100644 --- a/app/src/main/kotlin/dev/soupslurpr/appverifier/ui/VerifyAppViewModel.kt +++ b/app/src/main/kotlin/dev/soupslurpr/appverifier/ui/VerifyAppViewModel.kt @@ -271,6 +271,16 @@ class VerifyAppViewModel(application: Application) : AndroidViewModel(applicatio if (packageInfo == null) { setApkFailedToParse(true) + + val isFileDeleted = tempFile.delete() + + if (!isFileDeleted) { + throw IOException( + "Temporary APK file couldn't be deleted! Report this bug please with instructions " + + "on how to reproduce!" + ) + } + return }