+ /**
+ * Return the directory where to store temporary files for the remote
+ * {@link LocalLibrary}.
+ *
+ * @param host
+ * the remote for this host
+ *
+ * @return the directory
+ */
+ public static File getRemoteDir(String host) {
+ remoteDir.mkdirs();
+
+ if (host != null) {
+ return new File(remoteDir, host);
+ }
+
+ return remoteDir;
+ }
+
+ /**
+ * Check if we need to check that a new version of Fanfix is available.
+ *
+ * @return TRUE if we need to
+ */
+ public static boolean isVersionCheckNeeded() {
+ try {
+ long wait = config.getInteger(Config.UPDATE_INTERVAL, 1) * 24 * 60
+ * 60 * 1000;
+ if (wait >= 0) {
+ String lastUpString = IOUtils.readSmallFile(new File(configDir,
+ "LAST_UPDATE"));
+ long delay = new Date().getTime()
+ - Long.parseLong(lastUpString);
+ if (delay > wait) {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ } catch (Exception e) {
+ // No file or bad file:
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Notify that we checked for a new version of Fanfix.
+ */
+ public static void setVersionChecked() {
+ try {
+ IOUtils.writeSmallFile(new File(configDir), "LAST_UPDATE",
+ Long.toString(new Date().getTime()));
+ } catch (IOException e) {
+ syserr(e);
+ }
+ }
+