mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-11 01:20:16 +02:00
More resilient release asset import (if Downloads inaccessible, use export dir)
This commit is contained in:
@@ -943,6 +943,17 @@ class AppsProvider with ChangeNotifier {
|
|||||||
|
|
||||||
Future<void> downloadFn(MapEntry<String, String> fileUrl, App app) async {
|
Future<void> downloadFn(MapEntry<String, String> fileUrl, App app) async {
|
||||||
try {
|
try {
|
||||||
|
var exportDir = await settingsProvider.getExportDir();
|
||||||
|
String downloadPath = '/storage/emulated/0/Download';
|
||||||
|
bool downloadsAccessible = false;
|
||||||
|
try {
|
||||||
|
downloadsAccessible = Directory(downloadPath).existsSync();
|
||||||
|
} catch (e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
if (!downloadsAccessible && exportDir != null) {
|
||||||
|
downloadPath = exportDir.path;
|
||||||
|
}
|
||||||
await downloadFile(
|
await downloadFile(
|
||||||
fileUrl.value,
|
fileUrl.value,
|
||||||
fileUrl.key
|
fileUrl.key
|
||||||
@@ -954,7 +965,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
.join('.'), (double? progress) {
|
.join('.'), (double? progress) {
|
||||||
notificationsProvider
|
notificationsProvider
|
||||||
.notify(DownloadNotification(fileUrl.key, progress?.ceil() ?? 0));
|
.notify(DownloadNotification(fileUrl.key, progress?.ceil() ?? 0));
|
||||||
}, '/storage/emulated/0/Download',
|
}, downloadPath,
|
||||||
headers: await SourceProvider()
|
headers: await SourceProvider()
|
||||||
.getSource(app.url, overrideSource: app.overrideSource)
|
.getSource(app.url, overrideSource: app.overrideSource)
|
||||||
.getRequestHeaders(app.additionalSettings,
|
.getRequestHeaders(app.additionalSettings,
|
||||||
|
Reference in New Issue
Block a user