From 575979b0c3d6a86bb1382923e898d8a2441f82f1 Mon Sep 17 00:00:00 2001 From: Matthew Fosse Date: Thu, 16 Jan 2025 14:31:51 -0800 Subject: [PATCH] save to downloads would require an additional permission --- lib/src/screens/settings/mweb_logs_page.dart | 17 +++++------------ .../settings/mweb_settings_view_model.dart | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/src/screens/settings/mweb_logs_page.dart b/lib/src/screens/settings/mweb_logs_page.dart index 3c29ecdd85..ae476052e3 100644 --- a/lib/src/screens/settings/mweb_logs_page.dart +++ b/lib/src/screens/settings/mweb_logs_page.dart @@ -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); @@ -102,11 +99,7 @@ class MwebLogsPage extends BasePage { Future 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 _saveFile() async { diff --git a/lib/view_model/settings/mweb_settings_view_model.dart b/lib/view_model/settings/mweb_settings_view_model.dart index 583a62771f..3b0fa620a4 100644 --- a/lib/view_model/settings/mweb_settings_view_model.dart +++ b/lib/view_model/settings/mweb_settings_view_model.dart @@ -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,