From b7a9d524cb2b5a5bd2d6be2ff992d53f3201ff8a Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 7 Nov 2013 07:43:58 +0000 Subject: [PATCH] * exit on -clear-cache or -clear-prefs --- source/net/sourceforge/filebot/Main.java | 43 ++++++++++++++---------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/source/net/sourceforge/filebot/Main.java b/source/net/sourceforge/filebot/Main.java index 7cd14239..2ac3f915 100644 --- a/source/net/sourceforge/filebot/Main.java +++ b/source/net/sourceforge/filebot/Main.java @@ -88,6 +88,31 @@ public class Main { System.exit(0); } + if (args.clearCache() || args.clearUserData()) { + if (args.clearUserData()) { + System.out.println("Reset preferences"); + Settings.forPackage(Main.class).clear(); + } + + if (args.clearCache()) { + // clear preferences and cache + System.out.println("Clear cache and temporary files"); + for (File cache : getApplicationFolder().listFiles(FOLDERS)) { + if (matches("cache|temp|grape", cache.getName())) { + for (File it : cache.listFiles()) { + delete(it); + } + } + } + + initializeCache(); + CacheManager.getInstance().clearAll(); + } + + // just clear cache and/or settings and then exit + System.exit(0); + } + // tee stdout and stderr to log file if set if (args.logFile != null) { File logFile = new File(args.logFile); @@ -118,24 +143,6 @@ public class Main { initializeCache(); initializeSecurityManager(); - if (args.clearUserData()) { - System.out.println("Reset preferences"); - Settings.forPackage(Main.class).clear(); - } - - if (args.clearCache()) { - // clear preferences and cache - System.out.println("Clear cache and temporary files"); - for (File cache : getApplicationFolder().listFiles(FOLDERS)) { - if (matches("cache|temp|grape", cache.getName())) { - for (File it : cache.listFiles()) { - delete(it); - } - } - } - CacheManager.getInstance().clearAll(); - } - // update system properties if (System.getProperty("http.agent") == null) { System.setProperty("http.agent", String.format("%s %s", getApplicationName(), getApplicationVersion()));