1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-24 16:58:51 -05:00

* exit on -clear-cache or -clear-prefs

This commit is contained in:
Reinhard Pointner 2013-11-07 07:43:58 +00:00
parent 41f08070e0
commit b7a9d524cb

View File

@ -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()));