From c67ea9e73d23e2fb2741f8a73288a74117eca89c Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 17 Mar 2018 20:18:03 +0700 Subject: [PATCH] Store user preferences to a XML file just in case system preferences subsystem (e.g. Windows Registry) has issues --- source/net/filebot/Main.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/net/filebot/Main.java b/source/net/filebot/Main.java index 62519260..f10ccf67 100644 --- a/source/net/filebot/Main.java +++ b/source/net/filebot/Main.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import java.util.logging.Handler; import java.util.logging.Level; +import java.util.prefs.Preferences; import javax.swing.JDialog; import javax.swing.JFrame; @@ -120,6 +121,21 @@ public class Main { // GUI mode => start user interface SwingUtilities.invokeLater(() -> { + // restore preferences on start if empty (TODO: remove after a few releases) + try { + if (Preferences.userNodeForPackage(Main.class).keys().length == 0) { + File f = ApplicationFolder.AppData.resolve("preferences.backup.xml"); + if (f.exists()) { + log.info("Restore user preferences: " + f); + Settings.restore(f); + } else { + log.info("No user preferences found: " + f); + } + } + } catch (Exception e) { + debug.log(Level.WARNING, "Failed to restore preferences", e); + } + startUserInterface(args); // run background tasks