mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-22 22:19:29 +02:00
Bugfix for enhanced version detection
This commit is contained in:
@@ -416,7 +416,15 @@ class AppsProvider with ChangeNotifier {
|
|||||||
app.installedVersion = null;
|
app.installedVersion = null;
|
||||||
modded = true;
|
modded = true;
|
||||||
} else if (installedInfo != null && app.installedVersion == null) {
|
} else if (installedInfo != null && app.installedVersion == null) {
|
||||||
app.installedVersion = installedInfo.versionName;
|
if (app.enhancedVersionDetection) {
|
||||||
|
app.installedVersion = installedInfo.versionName;
|
||||||
|
} else {
|
||||||
|
if (app.latestVersion.contains(installedInfo.versionName!)) {
|
||||||
|
app.installedVersion = app.latestVersion;
|
||||||
|
} else {
|
||||||
|
app.installedVersion = installedInfo.versionName;
|
||||||
|
}
|
||||||
|
}
|
||||||
modded = true;
|
modded = true;
|
||||||
} else if (installedInfo?.versionName != app.installedVersion &&
|
} else if (installedInfo?.versionName != app.installedVersion &&
|
||||||
app.enhancedVersionDetection &&
|
app.enhancedVersionDetection &&
|
||||||
|
@@ -27,13 +27,12 @@ class AppNames {
|
|||||||
|
|
||||||
class APKDetails {
|
class APKDetails {
|
||||||
late String version;
|
late String version;
|
||||||
|
late String versionFromSource;
|
||||||
late List<String> apkUrls;
|
late List<String> apkUrls;
|
||||||
late bool isStandardVersionName;
|
|
||||||
|
|
||||||
APKDetails(version, this.apkUrls) {
|
APKDetails(this.versionFromSource, this.apkUrls) {
|
||||||
var standardVersion = extractStandardVersionName(version);
|
version =
|
||||||
isStandardVersionName = standardVersion != null;
|
extractStandardVersionName(versionFromSource) ?? versionFromSource;
|
||||||
this.version = standardVersion ?? version;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +200,7 @@ ObtainiumError getObtainiumHttpError(Response res) {
|
|||||||
|
|
||||||
String? extractStandardVersionName(String version, {bool strict = false}) {
|
String? extractStandardVersionName(String version, {bool strict = false}) {
|
||||||
var match = RegExp(
|
var match = RegExp(
|
||||||
'${strict ? '^' : ''}[0-9]+(\\.[0-9]+)+(-(alpha|beta)\\+?[0-9]+)?${strict ? '\$' : ''}')
|
'${strict ? '^' : ''}[0-9]+(\\.[0-9]+)+(-(alpha|beta|ocs)([0-9]+|\\+[0-9]+)?)?${strict ? '\$' : ''}')
|
||||||
.firstMatch(version);
|
.firstMatch(version);
|
||||||
return match != null ? version.substring(match.start, match.end) : null;
|
return match != null ? version.substring(match.start, match.end) : null;
|
||||||
}
|
}
|
||||||
@@ -284,6 +283,12 @@ class SourceProvider {
|
|||||||
if (apk.apkUrls.isEmpty && !trackOnly) {
|
if (apk.apkUrls.isEmpty && !trackOnly) {
|
||||||
throw NoAPKError();
|
throw NoAPKError();
|
||||||
}
|
}
|
||||||
|
bool enhancedVersionDetection = apk.version != apk.versionFromSource &&
|
||||||
|
installedVersion != null &&
|
||||||
|
extractStandardVersionName(installedVersion, strict: true) != null;
|
||||||
|
if (!enhancedVersionDetection) {
|
||||||
|
apk.version = apk.versionFromSource;
|
||||||
|
}
|
||||||
String apkVersion = apk.version.replaceAll('/', '-');
|
String apkVersion = apk.version.replaceAll('/', '-');
|
||||||
return App(
|
return App(
|
||||||
id ??
|
id ??
|
||||||
@@ -302,10 +307,7 @@ class SourceProvider {
|
|||||||
DateTime.now(),
|
DateTime.now(),
|
||||||
pinned,
|
pinned,
|
||||||
trackOnly,
|
trackOnly,
|
||||||
apk.isStandardVersionName &&
|
enhancedVersionDetection);
|
||||||
(installedVersion == null ||
|
|
||||||
extractStandardVersionName(installedVersion, strict: true) !=
|
|
||||||
null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns errors in [results, errors] instead of throwing them
|
// Returns errors in [results, errors] instead of throwing them
|
||||||
|
Reference in New Issue
Block a user