Skip to content

Commit 2bbe82d

Browse files
committed
Fix hardcoded android logs dir. Might fix #1134 ?
1 parent d6bc8be commit 2bbe82d

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

lib/utilities/stack_file_system.dart

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import 'dart:io';
1212

13+
import 'package:path/path.dart' as path;
1314
import 'package:path_provider/path_provider.dart';
1415
import 'package:permission_handler/permission_handler.dart';
1516

@@ -40,14 +41,17 @@ abstract class StackFileSystem {
4041
if (Util.isArmLinux) {
4142
appDirectory = await getApplicationDocumentsDirectory();
4243
appDirectory = Directory(
43-
"${appDirectory.path}/.${AppConfig.appDefaultDataDirName}",
44+
path.join(appDirectory.path, ".${AppConfig.appDefaultDataDirName}"),
4445
);
4546
} else if (Platform.isLinux) {
4647
if (_overrideDesktopDirPath != null) {
4748
appDirectory = Directory(_overrideDesktopDirPath!);
4849
} else {
4950
appDirectory = Directory(
50-
"${Platform.environment['HOME']}/.${AppConfig.appDefaultDataDirName}",
51+
path.join(
52+
Platform.environment['HOME']!,
53+
".${AppConfig.appDefaultDataDirName}",
54+
),
5155
);
5256
}
5357
} else if (Platform.isWindows) {
@@ -62,7 +66,7 @@ abstract class StackFileSystem {
6266
} else {
6367
appDirectory = await getLibraryDirectory();
6468
appDirectory = Directory(
65-
"${appDirectory.path}/${AppConfig.appDefaultDataDirName}",
69+
path.join(appDirectory.path, AppConfig.appDefaultDataDirName),
6670
);
6771
}
6872
} else if (Platform.isIOS) {
@@ -86,7 +90,7 @@ abstract class StackFileSystem {
8690
static Future<Directory> applicationIsarDirectory() async {
8791
final root = await applicationRootDirectory();
8892
if (_createSubDirs) {
89-
final dir = Directory("${root.path}/isar");
93+
final dir = Directory(path.join(root.path, "isar"));
9094
if (!dir.existsSync()) {
9195
await dir.create();
9296
}
@@ -99,7 +103,7 @@ abstract class StackFileSystem {
99103
static Future<Directory> applicationDriftDirectory() async {
100104
final root = await applicationRootDirectory();
101105
if (_createSubDirs) {
102-
final dir = Directory("${root.path}/drift");
106+
final dir = Directory(path.join(root.path, "drift"));
103107
if (!dir.existsSync()) {
104108
await dir.create();
105109
}
@@ -126,7 +130,7 @@ abstract class StackFileSystem {
126130
static Future<Directory> applicationTorDirectory() async {
127131
final root = await applicationRootDirectory();
128132
if (_createSubDirs) {
129-
final dir = Directory("${root.path}/tor");
133+
final dir = Directory(path.join(root.path, "tor"));
130134
if (!dir.existsSync()) {
131135
await dir.create();
132136
}
@@ -139,7 +143,7 @@ abstract class StackFileSystem {
139143
static Future<Directory> applicationFiroCacheSQLiteDirectory() async {
140144
final root = await applicationRootDirectory();
141145
if (_createSubDirs) {
142-
final dir = Directory("${root.path}/sqlite/firo_cache");
146+
final dir = Directory(path.join(root.path, "sqlite", "firo_cache"));
143147
if (!dir.existsSync()) {
144148
await dir.create(recursive: true);
145149
}
@@ -152,7 +156,7 @@ abstract class StackFileSystem {
152156
static Future<Directory> applicationHiveDirectory() async {
153157
final root = await applicationRootDirectory();
154158
if (_createSubDirs) {
155-
final dir = Directory("${root.path}/hive");
159+
final dir = Directory(path.join(root.path, "hive"));
156160
if (!dir.existsSync()) {
157161
await dir.create();
158162
}
@@ -164,7 +168,7 @@ abstract class StackFileSystem {
164168

165169
static Future<Directory> applicationXelisDirectory() async {
166170
final root = await applicationRootDirectory();
167-
final dir = Directory("${root.path}${Platform.pathSeparator}xelis");
171+
final dir = Directory(path.join(root.path, "xelis"));
168172
if (!dir.existsSync()) {
169173
await dir.create();
170174
}
@@ -173,7 +177,7 @@ abstract class StackFileSystem {
173177

174178
static Future<Directory> applicationXelisTableDirectory() async {
175179
final xelis = await applicationXelisDirectory();
176-
final dir = Directory("${xelis.path}${Platform.pathSeparator}table");
180+
final dir = Directory(path.join(xelis.path, "table"));
177181
if (!dir.existsSync()) {
178182
await dir.create();
179183
}
@@ -183,7 +187,7 @@ abstract class StackFileSystem {
183187
static Future<void> initThemesDir() async {
184188
final root = await applicationRootDirectory();
185189

186-
final dir = Directory("${root.path}/themes");
190+
final dir = Directory(path.join(root.path, "themes"));
187191
if (!dir.existsSync()) {
188192
await dir.create();
189193
}
@@ -206,13 +210,18 @@ abstract class StackFileSystem {
206210
final Directory logsDir;
207211

208212
if (Platform.isIOS) {
209-
logsDir = Directory("${appDocsDir.path}/logs");
213+
logsDir = Directory(path.join(appDocsDir.path, "logs"));
210214
} else if (Platform.isMacOS || Platform.isLinux || Platform.isWindows) {
211215
// TODO check this is correct for macos
212-
logsDir = Directory("${appDocsDir.path}/$logsDirName");
216+
logsDir = Directory(path.join(appDocsDir.path, logsDirName));
213217
} else if (Platform.isAndroid) {
214218
await Permission.storage.request();
215-
logsDir = Directory("/storage/emulated/0/Documents/$logsDirName");
219+
final ext = await getExternalStorageDirectory();
220+
final rootPath = path.dirname(
221+
path.dirname(path.dirname(path.dirname(ext!.path))),
222+
);
223+
final logsDirPath = path.join(rootPath, "Documents", logsDirName);
224+
logsDir = Directory(logsDirPath);
216225
} else {
217226
throw Exception("Unsupported Platform");
218227
}

pubspec.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,18 +1574,18 @@ packages:
15741574
dependency: "direct main"
15751575
description:
15761576
name: permission_handler
1577-
sha256: "59adad729136f01ea9e35a48f5d1395e25cba6cea552249ddbe9cf950f5d7849"
1577+
sha256: "2d070d8684b68efb580a5997eb62f675e8a885ef0be6e754fb9ef489c177470f"
15781578
url: "https://pub.dev"
15791579
source: hosted
1580-
version: "11.4.0"
1580+
version: "12.0.0+1"
15811581
permission_handler_android:
15821582
dependency: transitive
15831583
description:
15841584
name: permission_handler_android
1585-
sha256: d3971dcdd76182a0c198c096b5db2f0884b0d4196723d21a866fc4cdea057ebc
1585+
sha256: "1e3bc410ca1bf84662104b100eb126e066cb55791b7451307f9708d4007350e6"
15861586
url: "https://pub.dev"
15871587
source: hosted
1588-
version: "12.1.0"
1588+
version: "13.0.1"
15891589
permission_handler_apple:
15901590
dependency: transitive
15911591
description:

scripts/app_config/templates/pubspec.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ dependencies:
7878
# Utility plugins
7979
http: ^0.13.0
8080
local_auth: ^2.3.0
81-
permission_handler: ^11.0.0
81+
permission_handler: ^12.0.0+1
8282
flutter_local_notifications: ^17.2.2
8383
rxdart: ^0.27.3
8484
zxcvbn: ^1.0.0

0 commit comments

Comments
 (0)