Skip to content

Commit e376da4

Browse files
committed
Save settings before shutdown/restart to prevent data loss
Added a call to `Context.API.SaveAppAllSettings()` before executing system shutdown, restart, or advanced restart operations. This ensures that any unsaved settings are persisted, reducing the risk of data loss during these actions.
1 parent 7f0851b commit e376da4

File tree

1 file changed

+9
-0
lines changed
  • Plugins/Flow.Launcher.Plugin.Sys

1 file changed

+9
-0
lines changed

Plugins/Flow.Launcher.Plugin.Sys/Main.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ private static List<Result> Commands(Query query)
211211
Localize.flowlauncher_plugin_sys_shutdown_computer(),
212212
MessageBoxButton.YesNo, MessageBoxImage.Warning);
213213

214+
// Save settings before shutdown to avoid data loss
215+
Context.API.SaveAppAllSettings();
216+
214217
if (result == MessageBoxResult.Yes)
215218
if (EnableShutdownPrivilege())
216219
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF, REASON);
@@ -232,6 +235,9 @@ private static List<Result> Commands(Query query)
232235
Localize.flowlauncher_plugin_sys_restart_computer(),
233236
MessageBoxButton.YesNo, MessageBoxImage.Warning);
234237

238+
// Save settings before restart to avoid data loss
239+
Context.API.SaveAppAllSettings();
240+
235241
if (result == MessageBoxResult.Yes)
236242
if (EnableShutdownPrivilege())
237243
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON);
@@ -253,6 +259,9 @@ private static List<Result> Commands(Query query)
253259
Localize.flowlauncher_plugin_sys_restart_computer(),
254260
MessageBoxButton.YesNo, MessageBoxImage.Warning);
255261

262+
// Save settings before restart to avoid data loss
263+
Context.API.SaveAppAllSettings();
264+
256265
if (result == MessageBoxResult.Yes)
257266
if (EnableShutdownPrivilege())
258267
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT | EXIT_WINDOWS_FLAGS.EWX_BOOTOPTIONS, REASON);

0 commit comments

Comments
 (0)