mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-06-17 08:24:45 +08:00
[Android] Try write to external storage first
This commit is contained in:
@@ -26,6 +26,29 @@ class LogsFile {
|
||||
await dir.create(recursive: true);
|
||||
}
|
||||
_cachedLogDirectory = dir;
|
||||
final d1 = _file(DateTime.now());
|
||||
if (d1 == null) {
|
||||
throw Exception("Failed to create log file.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
if (isAndroid) {
|
||||
try {
|
||||
final io.Directory? dir = await getExternalStorageDirectory();
|
||||
if (dir != null) {
|
||||
final d = fs.directory(path.join(dir.path, "logs"));
|
||||
if (!(await d.exists())) {
|
||||
await d.create(recursive: true);
|
||||
}
|
||||
_cachedLogDirectory = d;
|
||||
final d2 = _file(DateTime.now());
|
||||
if (d2 == null) {
|
||||
throw Exception("Failed to create log file.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -4,3 +4,4 @@ import 'package:flutter/foundation.dart';
|
||||
bool get isDesktop =>
|
||||
!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS);
|
||||
bool get isWindows => !kIsWeb && Platform.isWindows;
|
||||
bool get isAndroid => !kIsWeb && Platform.isAndroid;
|
||||
|
||||
Reference in New Issue
Block a user