Skip to content

Commit

Permalink
save to downloads would require an additional permission
Browse files Browse the repository at this point in the history
  • Loading branch information
fossephate committed Jan 16, 2025
1 parent 86a6812 commit 575979b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
17 changes: 5 additions & 12 deletions lib/src/screens/settings/mweb_logs_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,12 @@ class MwebLogsPage extends BasePage {
return AlertWithTwoActions(
alertTitle: S.of(context).export_backup,
alertContent: S.of(context).select_destination,
rightButtonText: S.of(context).save_to_downloads,
leftButtonText: S.of(context).share,
actionRightButton: () async {
final inAppPath = "${(await getApplicationSupportDirectory()).path}/logs/debug.log";
final localPath = "/storage/emulated/0/Download/debug.log";
await mwebSettingsViewModelBase.saveLogsLocally(inAppPath, localPath);
rightButtonText: S.of(context).save,
leftButtonText: S.of(context).cancel,
actionLeftButton: () async {
Navigator.of(dialogContext).pop();
},
actionLeftButton: () async {
actionRightButton: () async {
Navigator.of(dialogContext).pop();
try {
await share(context);
Expand All @@ -102,11 +99,7 @@ class MwebLogsPage extends BasePage {

Future<void> share(BuildContext context) async {
final inAppPath = "${(await getApplicationSupportDirectory()).path}/logs/debug.log";
final localPath = "/storage/emulated/0/Download/debug.log";
bool success = await mwebSettingsViewModelBase.saveLogsLocally(inAppPath, localPath);
if (!success) return;
await ShareUtil.shareFile(filePath: localPath, fileName: "debug.log", context: context);
await mwebSettingsViewModelBase.removeLogsLocally(localPath);
await ShareUtil.shareFile(filePath: inAppPath, fileName: "debug.log", context: context);
}

Future<void> _saveFile() async {
Expand Down
4 changes: 2 additions & 2 deletions lib/view_model/settings/mweb_settings_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ abstract class MwebSettingsViewModelBase with Store {
if (!logsFile.existsSync()) {
throw Exception('Logs file does not exist');
}
await logsFile.copy(localPath);
// await logsFile.copy(localPath);
await File(localPath).writeAsBytes(await logsFile.readAsBytes());
return true;
} catch (e, s) {
printV("@@@@@ ERROR SAVING LOGS @@@@@@@@");
ExceptionHandler.onError(FlutterErrorDetails(
exception: e,
stack: s,
Expand Down

0 comments on commit 575979b

Please sign in to comment.