mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-23 01:29:40 +02:00
Fix PathAccessException on secondary profiles (#1754)
This commit is contained in:
@@ -743,6 +743,10 @@ class AppsProvider with ChangeNotifier {
|
||||
return installed;
|
||||
}
|
||||
|
||||
Future<String> getStorageRootPath() async {
|
||||
return '/${(await getExternalStorageDirectory())!.uri.pathSegments.sublist(0, 3).join('/')}';
|
||||
}
|
||||
|
||||
Future<void> moveObbFile(File file, String appId) async {
|
||||
if (!file.path.toLowerCase().endsWith('.obb')) return;
|
||||
|
||||
@@ -751,7 +755,7 @@ class AppsProvider with ChangeNotifier {
|
||||
await Permission.storage.request();
|
||||
}
|
||||
|
||||
String obbDirPath = "/storage/emulated/0/Android/obb/$appId";
|
||||
String obbDirPath = "${await getStorageRootPath()}/Android/obb/$appId";
|
||||
Directory(obbDirPath).createSync(recursive: true);
|
||||
|
||||
String obbFileName = file.path.split("/").last;
|
||||
@@ -1045,10 +1049,11 @@ class AppsProvider with ChangeNotifier {
|
||||
Future<void> downloadFn(MapEntry<String, String> fileUrl, App app) async {
|
||||
try {
|
||||
var exportDir = await settingsProvider.getExportDir();
|
||||
String downloadPath = '/storage/emulated/0/Download';
|
||||
String downloadPath = '${await getStorageRootPath()}/Download';
|
||||
bool downloadsAccessible = false;
|
||||
try {
|
||||
downloadsAccessible = Directory(downloadPath).existsSync();
|
||||
Directory(downloadPath).listSync();
|
||||
downloadsAccessible = true;
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
|
Reference in New Issue
Block a user