mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-11-11 18:43:28 +01:00
Use alternative storage dir if user-accessible one is null (#2392)
This commit is contained in:
@@ -498,6 +498,10 @@ Future<PackageInfo?> getInstalledInfo(
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Directory> getAppStorageDir() async =>
|
||||||
|
await getExternalStorageDirectory() ??
|
||||||
|
await getApplicationDocumentsDirectory();
|
||||||
|
|
||||||
class AppsProvider with ChangeNotifier {
|
class AppsProvider with ChangeNotifier {
|
||||||
// In memory App state (should always be kept in sync with local storage versions)
|
// In memory App state (should always be kept in sync with local storage versions)
|
||||||
Map<String, AppInMemory> apps = {};
|
Map<String, AppInMemory> apps = {};
|
||||||
@@ -534,15 +538,11 @@ class AppsProvider with ChangeNotifier {
|
|||||||
iconsCacheDir.createSync();
|
iconsCacheDir.createSync();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
APKDir = Directory(
|
APKDir = Directory('${(await getAppStorageDir()).path}/apks');
|
||||||
'${(await getExternalStorageDirectory())!.path}/apks',
|
|
||||||
);
|
|
||||||
if (!APKDir.existsSync()) {
|
if (!APKDir.existsSync()) {
|
||||||
APKDir.createSync();
|
APKDir.createSync();
|
||||||
}
|
}
|
||||||
iconsCacheDir = Directory(
|
iconsCacheDir = Directory('${(await getAppStorageDir()).path}/icons');
|
||||||
'${(await getExternalStorageDirectory())!.path}/icons',
|
|
||||||
);
|
|
||||||
if (!iconsCacheDir.existsSync()) {
|
if (!iconsCacheDir.existsSync()) {
|
||||||
iconsCacheDir.createSync();
|
iconsCacheDir.createSync();
|
||||||
}
|
}
|
||||||
@@ -1002,7 +1002,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getStorageRootPath() async {
|
Future<String> getStorageRootPath() async {
|
||||||
return '/${(await getExternalStorageDirectory())!.uri.pathSegments.sublist(0, 3).join('/')}';
|
return '/${(await getAppStorageDir()).uri.pathSegments.sublist(0, 3).join('/')}';
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> moveObbFile(File file, String appId) async {
|
Future<void> moveObbFile(File file, String appId) async {
|
||||||
@@ -1449,7 +1449,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
|
|
||||||
Future<Directory> getAppsDir() async {
|
Future<Directory> getAppsDir() async {
|
||||||
Directory appsDir = Directory(
|
Directory appsDir = Directory(
|
||||||
'${(await getExternalStorageDirectory())!.path}/app_data',
|
'${(await getAppStorageDir()).path}/app_data',
|
||||||
);
|
);
|
||||||
if (!appsDir.existsSync()) {
|
if (!appsDir.existsSync()) {
|
||||||
appsDir.createSync();
|
appsDir.createSync();
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import 'package:obtainium/app_sources/github.dart';
|
|||||||
import 'package:obtainium/main.dart';
|
import 'package:obtainium/main.dart';
|
||||||
import 'package:obtainium/providers/apps_provider.dart';
|
import 'package:obtainium/providers/apps_provider.dart';
|
||||||
import 'package:obtainium/providers/source_provider.dart';
|
import 'package:obtainium/providers/source_provider.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:shared_storage/shared_storage.dart' as saf;
|
import 'package:shared_storage/shared_storage.dart' as saf;
|
||||||
@@ -35,7 +34,7 @@ class SettingsProvider with ChangeNotifier {
|
|||||||
// Not done in constructor as we want to be able to await it
|
// Not done in constructor as we want to be able to await it
|
||||||
Future<void> initializeSettings() async {
|
Future<void> initializeSettings() async {
|
||||||
prefs = await SharedPreferences.getInstance();
|
prefs = await SharedPreferences.getInstance();
|
||||||
defaultAppDir = (await getExternalStorageDirectory())!.path;
|
defaultAppDir = (await getAppStorageDir()).path;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user