Refactor
This commit is contained in:
parent
76f275ebae
commit
0e70aac95a
|
@ -1,7 +1,6 @@
|
|||
package net.filebot;
|
||||
|
||||
import static java.awt.GraphicsEnvironment.*;
|
||||
import static java.util.regex.Pattern.*;
|
||||
import static javax.swing.JOptionPane.*;
|
||||
import static net.filebot.Logging.*;
|
||||
import static net.filebot.Settings.*;
|
||||
|
@ -95,13 +94,11 @@ public class Main {
|
|||
if (args.clearCache()) {
|
||||
// clear preferences and cache
|
||||
log.info("Clear cache and temporary files");
|
||||
for (File folder : getChildren(getApplicationFolder().getAbsoluteFile(), FOLDERS)) {
|
||||
if (matches("cache|temp|grape|reports|logs", folder.getName())) {
|
||||
for (File folder : getChildren(getApplicationFolder().getCanonicalFile(), FOLDERS)) {
|
||||
if (delete(folder)) {
|
||||
log.config("* Delete " + folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initializeCache();
|
||||
CacheManager.getInstance().clearAll();
|
||||
|
@ -136,8 +133,7 @@ public class Main {
|
|||
}
|
||||
|
||||
// make sure java.io.tmpdir exists
|
||||
File tmpdir = new File(System.getProperty("java.io.tmpdir"));
|
||||
createFolders(tmpdir);
|
||||
createFolders(getApplicationTempFolder());
|
||||
|
||||
// initialize this stuff before anything else
|
||||
initializeCache();
|
||||
|
@ -149,22 +145,16 @@ public class Main {
|
|||
System.setProperty("grape.root", new File(getApplicationFolder(), "grape").getAbsolutePath());
|
||||
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
|
||||
|
||||
if (args.unixfs) {
|
||||
System.setProperty("unixfs", "true");
|
||||
}
|
||||
if (args.disableExtendedAttributes) {
|
||||
System.setProperty("useExtendedFileAttributes", "false");
|
||||
System.setProperty("useCreationDate", "false");
|
||||
}
|
||||
if (args.action.equalsIgnoreCase("test")) {
|
||||
System.setProperty("application.rename.history", "false"); // don't keep history of --action test rename operations
|
||||
}
|
||||
System.setProperty("unixfs", Boolean.toString(args.unixfs));
|
||||
System.setProperty("useExtendedFileAttributes", Boolean.toString(!args.disableExtendedAttributes));
|
||||
System.setProperty("useCreationDate", Boolean.toString(!args.disableExtendedAttributes));
|
||||
System.setProperty("application.rename.history", Boolean.toString(!args.action.equalsIgnoreCase("test"))); // don't keep history of --action test rename operations
|
||||
|
||||
// make sure we can access application arguments at any time
|
||||
Settings.setApplicationArgumentArray(argumentArray);
|
||||
setApplicationArgumentArray(argumentArray);
|
||||
|
||||
// initialize history spooler
|
||||
HistorySpooler.getInstance().setPersistentHistoryEnabled(System.getProperty("application.rename.history") == null ? true : Boolean.parseBoolean(System.getProperty("application.rename.history")));
|
||||
HistorySpooler.getInstance().setPersistentHistoryEnabled(useRenameHistory());
|
||||
|
||||
// CLI mode => run command-line interface and then exit
|
||||
if (args.runCLI()) {
|
||||
|
@ -459,6 +449,7 @@ public class Main {
|
|||
private static void initializeCache() throws Exception {
|
||||
// prepare cache folder for this application instance
|
||||
File cacheRoot = getApplicationCache();
|
||||
createFolders(cacheRoot);
|
||||
|
||||
try {
|
||||
for (int i = 0; true; i++) {
|
||||
|
|
|
@ -79,6 +79,10 @@ public final class Settings {
|
|||
return Boolean.parseBoolean(System.getProperty("useCreationDate"));
|
||||
}
|
||||
|
||||
public static boolean useRenameHistory() {
|
||||
return Boolean.parseBoolean(System.getProperty("application.rename.history", "true"));
|
||||
}
|
||||
|
||||
public static String getApplicationDeployment() {
|
||||
return System.getProperty("application.deployment", "jar");
|
||||
}
|
||||
|
@ -165,14 +169,11 @@ public final class Settings {
|
|||
cacheFolder = new File(getApplicationFolder(), "cache");
|
||||
}
|
||||
|
||||
// create folder if necessary
|
||||
try {
|
||||
createFolders(cacheFolder);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("application.cache", e);
|
||||
return cacheFolder;
|
||||
}
|
||||
|
||||
return cacheFolder;
|
||||
public static File getApplicationTempFolder() {
|
||||
return new File(System.getProperty("java.io.tmpdir"));
|
||||
}
|
||||
|
||||
public static File getRealUserHome() {
|
||||
|
|
Loading…
Reference in New Issue