1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-25 01:08:52 -05:00

* always display update notifications for outdated filebot installs

This commit is contained in:
Reinhard Pointner 2013-10-17 07:11:03 +00:00
parent 492c5b31b3
commit 02cd92d842

View File

@ -1,7 +1,5 @@
package net.sourceforge.filebot; package net.sourceforge.filebot;
import static java.awt.GraphicsEnvironment.*; import static java.awt.GraphicsEnvironment.*;
import static java.util.regex.Pattern.*; import static java.util.regex.Pattern.*;
import static javax.swing.JOptionPane.*; import static javax.swing.JOptionPane.*;
@ -68,7 +66,6 @@ import net.sourceforge.tuned.TeePrintStream;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
public class Main { public class Main {
/** /**
@ -155,11 +152,12 @@ public class Main {
if (args.action.equalsIgnoreCase("test")) { if (args.action.equalsIgnoreCase("test")) {
System.setProperty("useExtendedFileAttributes", "false"); System.setProperty("useExtendedFileAttributes", "false");
System.setProperty("application.analytics", "false"); System.setProperty("application.analytics", "false");
HistorySpooler.getInstance().setPersistentHistoryEnabled(false); // don't keep history of --action test rename operations System.setProperty("application.rename.history", "false"); // don't keep history of --action test rename operations
} }
// initialize analytics // initialize analytics
Analytics.setEnabled(System.getProperty("application.analytics") == null ? true : Boolean.parseBoolean(System.getProperty("application.analytics"))); Analytics.setEnabled(System.getProperty("application.analytics") == null ? true : Boolean.parseBoolean(System.getProperty("application.analytics")));
HistorySpooler.getInstance().setPersistentHistoryEnabled(System.getProperty("application.rename.history") == null ? true : Boolean.parseBoolean(System.getProperty("application.rename.history")));
// CLI mode => run command-line interface and then exit // CLI mode => run command-line interface and then exit
if (args.runCLI()) { if (args.runCLI()) {
@ -239,7 +237,6 @@ public class Main {
} }
} }
private static void startUserInterface(ArgumentBean args) { private static void startUserInterface(ArgumentBean args) {
JFrame frame = null; JFrame frame = null;
@ -285,13 +282,11 @@ public class Main {
frame.setVisible(true); frame.setVisible(true);
} }
/** /**
* Show update notifications if updates are available * Show update notifications if updates are available
*/ */
private static void checkUpdate() throws Exception { private static void checkUpdate() throws Exception {
final PreferencesEntry<String> updateIgnoreRevision = Settings.forPackage(Main.class).entry("update.revision.ignore"); final Properties updateProperties = new CachedResource<Properties>(getApplicationProperty("update.url"), Properties.class, 24 * 60 * 60 * 1000, 0, 0) {
final Properties updateProperties = new CachedResource<Properties>(getApplicationProperty("update.url"), Properties.class, 24 * 60 * 60 * 1000) {
@Override @Override
public Properties process(ByteBuffer data) { public Properties process(ByteBuffer data) {
@ -310,9 +305,9 @@ public class Main {
// check if update is required // check if update is required
int latestRev = Integer.parseInt(updateProperties.getProperty("revision")); int latestRev = Integer.parseInt(updateProperties.getProperty("revision"));
int latestIgnoreRev = Math.max(getApplicationRevisionNumber(), updateIgnoreRevision.getValue() == null ? 0 : Integer.parseInt(updateIgnoreRevision.getValue())); int currentRev = getApplicationRevisionNumber();
if (latestRev > latestIgnoreRev) { if (latestRev > currentRev && currentRev > 0) {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
@ -351,7 +346,6 @@ public class Main {
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
updateIgnoreRevision.setValue(updateProperties.getProperty("revision"));
dialog.setVisible(false); dialog.setVisible(false);
} }
}), "tag cancel"); }), "tag cancel");
@ -364,7 +358,6 @@ public class Main {
} }
} }
private static void showDonationReminder() { private static void showDonationReminder() {
int renameCount = HistorySpooler.getInstance().getPersistentHistoryTotalSize(); int renameCount = HistorySpooler.getInstance().getPersistentHistoryTotalSize();
if (renameCount < 2000) if (renameCount < 2000)
@ -396,7 +389,6 @@ public class Main {
Analytics.trackEvent("GUI", "Donate", "r" + currentRev, pane.getValue() == actions[0] ? 1 : 0); Analytics.trackEvent("GUI", "Donate", "r" + currentRev, pane.getValue() == actions[0] ? 1 : 0);
} }
private static void warmupCachedResources() { private static void warmupCachedResources() {
Thread warmup = new Thread("warmupCachedResources") { Thread warmup = new Thread("warmupCachedResources") {
@ -428,7 +420,6 @@ public class Main {
warmup.start(); warmup.start();
} }
private static void restoreWindowBounds(final JFrame window, final Settings settings) { private static void restoreWindowBounds(final JFrame window, final Settings settings) {
// store bounds on close // store bounds on close
window.addWindowListener(new WindowAdapter() { window.addWindowListener(new WindowAdapter() {
@ -453,7 +444,6 @@ public class Main {
window.setBounds(x, y, width, height); window.setBounds(x, y, width, height);
} }
/** /**
* Shutdown ehcache properly, so that disk-persistent stores can actually be saved to disk * Shutdown ehcache properly, so that disk-persistent stores can actually be saved to disk
*/ */
@ -513,7 +503,6 @@ public class Main {
System.setProperty("ehcache.disk.store.dir", new File(cacheRoot, "default").getAbsolutePath()); System.setProperty("ehcache.disk.store.dir", new File(cacheRoot, "default").getAbsolutePath());
} }
/** /**
* Initialize default SecurityManager and grant all permissions via security policy. Initialization is required in order to run {@link ExpressionFormat} in a secure sandbox. * Initialize default SecurityManager and grant all permissions via security policy. Initialization is required in order to run {@link ExpressionFormat} in a secure sandbox.
*/ */
@ -529,7 +518,6 @@ public class Main {
return true; return true;
} }
@Override @Override
public PermissionCollection getPermissions(CodeSource codesource) { public PermissionCollection getPermissions(CodeSource codesource) {
// VisualVM can't connect if this method does return // VisualVM can't connect if this method does return