mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-01 21:30:16 +02:00
Merge branch 'main' into re7gog
# Conflicts: # pubspec.lock
This commit is contained in:
@@ -244,16 +244,17 @@ class HTML extends AppSource {
|
||||
true) {
|
||||
var reg = RegExp(additionalSettings['customLinkFilterRegex']);
|
||||
links = allLinks
|
||||
.where((element) =>
|
||||
reg.hasMatch(filterLinkByText ? element.value : element.key))
|
||||
.where((element) => reg.hasMatch(
|
||||
filterLinkByText ? element.value : Uri.decodeFull(element.key)))
|
||||
.toList();
|
||||
} else {
|
||||
links = allLinks
|
||||
.where((element) =>
|
||||
Uri.parse(filterLinkByText ? element.value : element.key)
|
||||
.path
|
||||
.toLowerCase()
|
||||
.endsWith('.apk'))
|
||||
.where((element) => Uri.parse(filterLinkByText
|
||||
? element.value
|
||||
: Uri.decodeFull(element.key))
|
||||
.path
|
||||
.toLowerCase()
|
||||
.endsWith('.apk'))
|
||||
.toList();
|
||||
}
|
||||
if (!skipSort) {
|
||||
@@ -315,7 +316,7 @@ class HTML extends AppSource {
|
||||
additionalSettings['matchGroupToUse'] as String?,
|
||||
additionalSettings['versionExtractWholePage'] == true
|
||||
? versionExtractionWholePageString
|
||||
: rel);
|
||||
: Uri.decodeFull(rel));
|
||||
version ??=
|
||||
additionalSettings['defaultPseudoVersioningMethod'] == 'APKLinkHash'
|
||||
? rel.hashCode.toString()
|
||||
|
@@ -245,8 +245,8 @@ class _GeneratedFormState extends State<GeneratedForm> {
|
||||
void someValueChanged({bool isBuilding = false, bool forceInvalid = false}) {
|
||||
Map<String, dynamic> returnValues = values;
|
||||
var valid = true;
|
||||
for (int r = 0; r < widget.items.length; r++) {
|
||||
for (int i = 0; i < widget.items[r].length; i++) {
|
||||
for (int r = 0; r < formInputs.length; r++) {
|
||||
for (int i = 0; i < formInputs[r].length; i++) {
|
||||
if (formInputs[r][i] is TextFormField) {
|
||||
valid = valid && validateTextField(formInputs[r][i] as TextFormField);
|
||||
}
|
||||
|
@@ -235,8 +235,9 @@ Future<File> downloadFile(
|
||||
var fullContentLength = response.contentLength;
|
||||
if (useExisting && downloadedFile.existsSync()) {
|
||||
var length = downloadedFile.lengthSync();
|
||||
if (fullContentLength == null) {
|
||||
// Assume full
|
||||
if (fullContentLength == null || !rangeFeatureEnabled) {
|
||||
// If there is no content length reported, assume it the existing file is fully downloaded
|
||||
// Also if the range feature is not supported, don't trust the content length if any (#1542)
|
||||
client.close();
|
||||
return downloadedFile;
|
||||
} else {
|
||||
@@ -291,14 +292,11 @@ Future<File> downloadFile(
|
||||
return s;
|
||||
}).pipe(sink);
|
||||
await sink.close();
|
||||
bool likelyCorruptFile = (progress ?? 0) > 101;
|
||||
progress = null;
|
||||
if (onProgress != null) {
|
||||
onProgress(progress);
|
||||
}
|
||||
if (response.statusCode < 200 ||
|
||||
response.statusCode > 299 ||
|
||||
likelyCorruptFile) {
|
||||
if (response.statusCode < 200 || response.statusCode > 299) {
|
||||
tempDownloadedFile.deleteSync(recursive: true);
|
||||
throw response.reasonPhrase ?? tr('unexpectedError');
|
||||
}
|
||||
@@ -392,30 +390,26 @@ class AppsProvider with ChangeNotifier {
|
||||
}();
|
||||
}
|
||||
|
||||
Future<File> handleAPKIDChange(App app, PackageInfo? newInfo,
|
||||
Future<File> handleAPKIDChange(App app, PackageInfo newInfo,
|
||||
File downloadedFile, String downloadUrl) async {
|
||||
// If the APK package ID is different from the App ID, it is either new (using a placeholder ID) or the ID has changed
|
||||
// The former case should be handled (give the App its real ID), the latter is a security issue
|
||||
var isTempIdBool = isTempId(app);
|
||||
if (newInfo != null) {
|
||||
if (app.id != newInfo.packageName) {
|
||||
if (apps[app.id] != null && !isTempIdBool && !app.allowIdChange) {
|
||||
throw IDChangedError(newInfo.packageName!);
|
||||
}
|
||||
var idChangeWasAllowed = app.allowIdChange;
|
||||
app.allowIdChange = false;
|
||||
var originalAppId = app.id;
|
||||
app.id = newInfo.packageName!;
|
||||
downloadedFile = downloadedFile.renameSync(
|
||||
'${downloadedFile.parent.path}/${app.id}-${downloadUrl.hashCode}.${downloadedFile.path.split('.').last}');
|
||||
if (apps[originalAppId] != null) {
|
||||
await removeApps([originalAppId]);
|
||||
await saveApps([app],
|
||||
onlyIfExists: !isTempIdBool && !idChangeWasAllowed);
|
||||
}
|
||||
if (app.id != newInfo.packageName) {
|
||||
if (apps[app.id] != null && !isTempIdBool && !app.allowIdChange) {
|
||||
throw IDChangedError(newInfo.packageName!);
|
||||
}
|
||||
var idChangeWasAllowed = app.allowIdChange;
|
||||
app.allowIdChange = false;
|
||||
var originalAppId = app.id;
|
||||
app.id = newInfo.packageName!;
|
||||
downloadedFile = downloadedFile.renameSync(
|
||||
'${downloadedFile.parent.path}/${app.id}-${downloadUrl.hashCode}.${downloadedFile.path.split('.').last}');
|
||||
if (apps[originalAppId] != null) {
|
||||
await removeApps([originalAppId]);
|
||||
await saveApps([app],
|
||||
onlyIfExists: !isTempIdBool && !idChangeWasAllowed);
|
||||
}
|
||||
} else if (isTempIdBool) {
|
||||
throw ObtainiumError('Could not get ID from APK');
|
||||
}
|
||||
return downloadedFile;
|
||||
}
|
||||
@@ -479,6 +473,10 @@ class AppsProvider with ChangeNotifier {
|
||||
newInfo =
|
||||
await pm.getPackageArchiveInfo(archiveFilePath: apks.first.path);
|
||||
}
|
||||
if (newInfo == null) {
|
||||
downloadedFile.delete();
|
||||
throw ObtainiumError('Could not get ID from APK');
|
||||
}
|
||||
downloadedFile =
|
||||
await handleAPKIDChange(app, newInfo, downloadedFile, downloadUrl);
|
||||
// Delete older versions of the file if any
|
||||
|
Reference in New Issue
Block a user