mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-20 21:19:29 +02:00
Better partial APK hash as pseudo-version (related to #1101)
This commit is contained in:
@@ -310,7 +310,7 @@ class HTML extends AppSource {
|
|||||||
: rel);
|
: rel);
|
||||||
version ??= additionalSettings['supportFixedAPKURL'] != true
|
version ??= additionalSettings['supportFixedAPKURL'] != true
|
||||||
? rel.hashCode.toString()
|
? rel.hashCode.toString()
|
||||||
: (await checkDownloadHash(rel)).toString();
|
: (await checkPartialDownloadHashDynamc(rel)).toString();
|
||||||
return APKDetails(version, [rel].map((e) => MapEntry(e, e)).toList(),
|
return APKDetails(version, [rel].map((e) => MapEntry(e, e)).toList(),
|
||||||
AppNames(uri.host, tr('app')));
|
AppNames(uri.host, tr('app')));
|
||||||
}
|
}
|
||||||
|
@@ -167,8 +167,25 @@ String hashListOfLists(List<List<int>> data) {
|
|||||||
return hash.hashCode.toString();
|
return hash.hashCode.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> checkDownloadHash(String url,
|
Future<String> checkPartialDownloadHashDynamc(String url,
|
||||||
{int bytesToGrab = 1024, Map<String, String>? headers}) async {
|
{int startingSize = 1024,
|
||||||
|
int lowerLimit = 128,
|
||||||
|
Map<String, String>? headers}) async {
|
||||||
|
for (int i = startingSize; i >= lowerLimit; i -= 256) {
|
||||||
|
List<String> ab = await Future.wait([
|
||||||
|
checkPartialDownloadHash(url, i, headers: headers),
|
||||||
|
checkPartialDownloadHash(url, i, headers: headers)
|
||||||
|
]);
|
||||||
|
if (ab[0] == ab[1]) {
|
||||||
|
print(i);
|
||||||
|
return ab[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw NoVersionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> checkPartialDownloadHash(String url, int bytesToGrab,
|
||||||
|
{Map<String, String>? headers}) async {
|
||||||
var req = Request('GET', Uri.parse(url));
|
var req = Request('GET', Uri.parse(url));
|
||||||
if (headers != null) {
|
if (headers != null) {
|
||||||
req.headers.addAll(headers);
|
req.headers.addAll(headers);
|
||||||
|
Reference in New Issue
Block a user