X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2FInstance.java;h=2479c612dc45b97cf224158c36640c88721ecc42;hb=b7cd9db81ba27c67fdd8dd5a42b5f9e4137622db;hp=8a2ed98a702144f1ece1c135964881435fd0952f;hpb=70f368f43e8a454bf5fd07bd8c44e80f93657680;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/Instance.java b/src/be/nikiroo/fanfix/Instance.java index 8a2ed98..2479c61 100644 --- a/src/be/nikiroo/fanfix/Instance.java +++ b/src/be/nikiroo/fanfix/Instance.java @@ -47,11 +47,32 @@ public class Instance { /** * Initialise the instance -- if already initialised, nothing will happen. *

- * Before calling this method, you may call {@link Bundles#setDirectory()} - * if wanted. + * Before calling this method, you may call + * {@link Bundles#setDirectory(String)} if wanted. */ static public void init() { - if (init) { + init(false); + } + + /** + * Initialise the instance -- if already initialised, nothing will happen + * unless you pass TRUE to force. + *

+ * Before calling this method, you may call + * {@link Bundles#setDirectory(String)} if wanted. + *

+ * Note: forcing the initialisation can be dangerous, so make sure to only + * make it under controlled circumstances -- for instance, at the start of + * the program, you could call {@link Instance#init()}, change some settings + * because you want to force those settings (it will also forbid users to + * change them!) and then call {@link Instance#init(boolean)} with + * force set to TRUE. + * + * @param force + * force the initialisation even if already initialised + */ + static public void init(boolean force) { + if (init && !force) { return; } @@ -93,11 +114,10 @@ public class Instance { // Could have used: System.getProperty("java.io.tmpdir") tmp = new File(configDir, "tmp"); } - String ua = config.getString(Config.USER_AGENT); + String ua = config.getString(Config.USER_AGENT, ""); try { - int hours = config.getInteger(Config.CACHE_MAX_TIME_CHANGING, -1); - int hoursLarge = config - .getInteger(Config.CACHE_MAX_TIME_STABLE, -1); + int hours = config.getInteger(Config.CACHE_MAX_TIME_CHANGING, 0); + int hoursLarge = config.getInteger(Config.CACHE_MAX_TIME_STABLE, 0); cache = new DataLoader(tmp, ua, hours, hoursLarge); } catch (IOException e) { tracer.error(new IOException( @@ -311,7 +331,7 @@ public class Instance { */ public static boolean isVersionCheckNeeded() { try { - long wait = config.getInteger(Config.UPDATE_INTERVAL, 1) * 24 * 60 + long wait = config.getInteger(Config.UPDATE_INTERVAL, 0) * 24 * 60 * 60 * 1000; if (wait >= 0) { String lastUpString = IOUtils.readSmallFile(new File(configDir,