Correctly report and auto-delete bad APKs (#1251)

This commit is contained in:
Imran Remtulla
2024-02-01 19:26:36 -05:00
parent a3530ce6bb
commit e278c9fb5a
19 changed files with 28 additions and 1 deletions

View File

@@ -532,9 +532,18 @@ class AppsProvider with ChangeNotifier {
{bool needsBGWorkaround = false}) async {
var newInfo =
await pm.getPackageArchiveInfo(archiveFilePath: file.file.path);
if (newInfo == null) {
try {
file.file.deleteSync(recursive: true);
} catch (e) {
//
} finally {
throw ObtainiumError(tr('badDownload'));
}
}
PackageInfo? appInfo = await getInstalledInfo(apps[file.appId]!.app.id);
if (appInfo != null &&
newInfo!.versionCode! < appInfo.versionCode! &&
newInfo.versionCode! < appInfo.versionCode! &&
!(await canDowngradeApps())) {
throw DowngradeError();
}