Fix Uptodown - was completely broken (#1796)

This commit is contained in:
Imran Remtulla
2024-08-19 22:37:57 -04:00
parent 514ca3e28b
commit 03778fd743
3 changed files with 31 additions and 12 deletions

View File

@@ -225,7 +225,9 @@ Future<File> downloadFile(String url, String fileName, bool fileNameHasExt,
ext != 'apk') {
ext = 'apk';
}
fileName = fileName.split('/').last; // Ensure the fileName is a file name
fileName = fileNameHasExt
? fileName
: fileName.split('/').last; // Ensure the fileName is a file name
File downloadedFile = File('$destDir/$fileName.$ext');
if (fileNameHasExt) {
// If the user says the filename already has an ext, ignore whatever you inferred from above
@@ -447,11 +449,15 @@ class AppsProvider with ChangeNotifier {
notificationsProvider?.cancel(notif.id);
int? prevProg;
var fileNameNoExt = '${app.id}-${downloadUrl.hashCode}';
if (source.urlsAlwaysHaveExtension) {
fileNameNoExt =
'$fileNameNoExt.${app.apkUrls[app.preferredApkIndex].key.split('.').last}';
}
var headers = await source.getRequestHeaders(app.additionalSettings,
forAPKDownload: true);
var downloadedFile = await downloadFileWithRetry(
downloadUrl, fileNameNoExt, false, headers: headers,
(double? progress) {
downloadUrl, fileNameNoExt, source.urlsAlwaysHaveExtension,
headers: headers, (double? progress) {
int? prog = progress?.ceil();
if (apps[app.id] != null) {
apps[app.id]!.downloadProgress = progress;

View File

@@ -412,6 +412,7 @@ abstract class AppSource {
bool showReleaseDateAsVersionToggle = false;
bool versionDetectionDisallowed = false;
List<String> excludeCommonSettingKeys = [];
bool urlsAlwaysHaveExtension = false;
AppSource() {
name = runtimeType.toString();