Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
* splitt off yacyRelease from yacyVersion * added some gui infos about signatures
f1oribde88b684a9b
diff --git a/defaults/yacy.init b/defaults/yacy.initindex 40713818c..2ac37df88 100644--- a/defaults/yacy.init+++ b/defaults/yacy.init@@ -112,6 +112,8 @@ update.time.deploy = 0# delete old downloaded files after this amount of days to free disk space# the latest release is always keptupdate.deleteOld = 30+# only install sign files+update.onlySignedFiles = 1# restart-option# a peer can be re-started periodicallydiff --git a/htroot/ConfigUpdate_p.html b/htroot/ConfigUpdate_p.htmlindex 3c03e5332..ad75cac6f 100644--- a/htroot/ConfigUpdate_p.html+++ b/htroot/ConfigUpdate_p.html@@ -25,7 +25,7 @@<dd><form action="ConfigUpdate_p.html" method="get"> <select name="releasedownload">#{availreleases}#- <option #(selected)#::selected#(/selected)# value="#[url]#">#[name]#</option>+ <option #(selected)#::selected#(/selected)# value="#[url]#">#[name]# #(signatures)#(unsigned)::(signed)#(/signatures)#</option>#{/availreleases}#</select> <input type="submit" name="downloadRelease" value="Download Release" />@@ -35,7 +35,7 @@<dd><form action="ConfigUpdate_p.html" method="get"> <select name="releaseinstall">#{downloadedreleases}#- <option #(selected)#::selected#(/selected)# value="#[file]#">#[name]#</option>+ <option #(selected)#::selected#(/selected)# value="#[file]#">#[name]# #(signature)#(no signature)::(signed)#(/signature)#</option>#{/downloadedreleases}#</select>#(deployenabled)#::no automated installation on development environments::@@ -88,6 +88,13 @@</dl></fieldset></dd>+ <dt>+ Signed autoupdate: + </dt>+ <dd>+ <input type="checkbox" name="onlySignedFiles" value="true" #(onlySignedFiles)#::checked="checked" #(/onlySignedFiles)#/>+ only accept signed files+ </dd><dt><input type="submit" name="configSubmit" value="Submit"></dt><dd>#(configCommit)#::<div class="commit">Accepted Changes.</div>#(/configCommit)#</dd></dl>diff --git a/htroot/ConfigUpdate_p.java b/htroot/ConfigUpdate_p.javaindex 61fe32018..1756f2205 100644--- a/htroot/ConfigUpdate_p.java+++ b/htroot/ConfigUpdate_p.java@@ -36,6 +36,7 @@ import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;import de.anomic.server.serverSystem;import de.anomic.yacy.yacyURL;+import de.anomic.yacy.yacyRelease;import de.anomic.yacy.yacyVersion;public class ConfigUpdate_p {@@ -62,13 +63,13 @@ public class ConfigUpdate_p {final String release = post.get("releasedownload", "");if (release.length() > 0) {try {- yacyVersion versionToDownload = new yacyVersion(new yacyURL(release, null));+ yacyRelease versionToDownload = new yacyRelease(new yacyURL(release, null));// replace this version with version which contains public key- yacyVersion.DevAndMainVersions allReleases = yacyVersion.allReleases(false);- TreeSet<yacyVersion> mostReleases = versionToDownload.mainRelease+ yacyRelease.DevAndMainVersions allReleases = yacyRelease.allReleases(false, false);+ TreeSet<yacyRelease> mostReleases = versionToDownload.isMainRelease()? allReleases.main : allReleases.dev;- for(yacyVersion rel : mostReleases) {+ for(yacyRelease rel : mostReleases) {if(rel.equals(versionToDownload)) {versionToDownload = rel;break;@@ -83,13 +84,14 @@ public class ConfigUpdate_p {}if (post.containsKey("checkRelease")) {- yacyVersion.allReleases(true);+ yacyRelease.allReleases(true, false);}if (post.containsKey("deleteRelease")) {final String release = post.get("releaseinstall", "");if(release.length() > 0) {try {FileUtils.deletedelete(new File(sb.releasePath, release));+ FileUtils.deletedelete(new File(sb.releasePath, release + ".sig"));} catch (final NullPointerException e) {sb.getLog().logSevere("AUTO-UPDATE: could not delete release " + release + ": " + e.getMessage());}@@ -97,14 +99,14 @@ public class ConfigUpdate_p {}if (post.containsKey("autoUpdate")) {- final yacyVersion updateVersion = yacyVersion.rulebasedUpdateInfo(true);+ final yacyRelease updateVersion = yacyRelease.rulebasedUpdateInfo(true);if (updateVersion == null) {prop.put("candeploy_autoUpdate", "2"); // no more recent release found} else {// there is a version that is more recent. Load it and re-start with it- sb.getLog().logInfo("AUTO-UPDATE: downloading more recent release " + updateVersion.url);+ sb.getLog().logInfo("AUTO-UPDATE: downloading more recent release " + updateVersion.getUrl());final File downloaded = updateVersion.downloadRelease();- prop.putHTML("candeploy_autoUpdate_downloadedRelease", updateVersion.name);+ prop.putHTML("candeploy_autoUpdate_downloadedRelease", updateVersion.getName());final boolean devenvironment = yacyVersion.combined2prettyVersion(sb.getConfig("version","0.1")).startsWith("dev");if (devenvironment) {sb.getLog().logInfo("AUTO-UPDATE: omiting update because this is a development environment");@@ -113,7 +115,7 @@ public class ConfigUpdate_p {sb.getLog().logInfo("AUTO-UPDATE: omiting update because download failed (file cannot be found, is too small or signature was bad)");prop.put("candeploy_autoUpdate", "4");} else {- yacyVersion.deployRelease(downloaded);+ yacyRelease.deployRelease(downloaded);sb.terminate(5000);sb.getLog().logInfo("AUTO-UPDATE: deploy and restart initiated");prop.put("candeploy_autoUpdate", "1");@@ -127,6 +129,7 @@ public class ConfigUpdate_p {sb.setConfig("update.cycle", Math.max(12, post.getLong("cycle", 168)));sb.setConfig("update.blacklist", post.get("blacklist", ""));sb.setConfig("update.concept", (post.get("releaseType", "any").equals("any")) ? "any" : "main");+ sb.setConfig("update.onlySignedFiles", (post.get("onlySignedFiles", "false").equals("true")) ? "1" : "0");}}@@ -153,10 +156,10 @@ public class ConfigUpdate_p {prop.put("candeploy_deployenabled", (downloadedFiles.length == 0) ? "0" : ((devenvironment) ? "1" : "2")); // prevent that a developer-version is over-deployed- final TreeSet<yacyVersion> downloadedReleases = new TreeSet<yacyVersion>();+ final TreeSet<yacyRelease> downloadedReleases = new TreeSet<yacyRelease>();for(File downloaded : downloadedFiles) {try {- yacyVersion release = new yacyVersion(downloaded);+ yacyRelease release = new yacyRelease(downloaded);downloadedReleases.add(release);} catch (final RuntimeException e) {// not a valid release@@ -169,35 +172,38 @@ public class ConfigUpdate_p {// latest downloaded releaseyacyVersion dflt = (downloadedReleases.size() == 0) ? null : downloadedReleases.last();int relcount = 0;- for(yacyVersion release : downloadedReleases) {- prop.put("candeploy_downloadedreleases_" + relcount + "_name", ((release.mainRelease) ? "main" : "dev") + " " + release.releaseNr + "/" + release.svn);- prop.putHTML("candeploy_downloadedreleases_" + relcount + "_file", release.name);+ for(yacyRelease release : downloadedReleases) {+ prop.put("candeploy_downloadedreleases_" + relcount + "_name", ((release.isMainRelease()) ? "main" : "dev") + " " + release.getReleaseNr() + "/" + release.getSvn());+ prop.put("candeploy_downloadedreleases_" + relcount + "_signature", (release.getSignatureFile().exists() ? "1" : "0"));+ prop.putHTML("candeploy_downloadedreleases_" + relcount + "_file", release.getName());prop.put("candeploy_downloadedreleases_" + relcount + "_selected", (release == dflt) ? "1" : "0");relcount++;}prop.put("candeploy_downloadedreleases", relcount);// list remotely available releases- final yacyVersion.DevAndMainVersions releasess = yacyVersion.allReleases(false);+ final yacyRelease.DevAndMainVersions releasess = yacyRelease.allReleases(false, false);relcount = 0;// main- final TreeSet<yacyVersion> remoteMainReleases = releasess.main;+ final TreeSet<yacyRelease> remoteMainReleases = releasess.main;remoteMainReleases.removeAll(downloadedReleases);- for (yacyVersion release : remoteMainReleases) {- prop.put("candeploy_availreleases_" + relcount + "_name", ((release.mainRelease) ? "main" : "dev") + " " + release.releaseNr + "/" + release.svn);- prop.put("candeploy_availreleases_" + relcount + "_url", release.url.toString());+ for (yacyRelease release : remoteMainReleases) {+ prop.put("candeploy_availreleases_" + relcount + "_name", ((release.isMainRelease()) ? "main" : "dev") + " " + release.getReleaseNr() + "/" + release.getSvn());+ prop.put("candeploy_availreleases_" + relcount + "_url", release.getUrl().toString());+ prop.put("candeploy_availreleases_" + relcount + "_signatures", (release.getPublicKey()!=null?"1":"0"));prop.put("candeploy_availreleases_" + relcount + "_selected", "0");relcount++;}// devdflt = (releasess.dev.size() == 0) ? null : releasess.dev.last();- final TreeSet<yacyVersion> remoteDevReleases = releasess.dev;+ final TreeSet<yacyRelease> remoteDevReleases = releasess.dev;remoteDevReleases.removeAll(downloadedReleases);- for(yacyVersion release : remoteDevReleases) {- prop.put("candeploy_availreleases_" + relcount + "_name", ((release.mainRelease) ? "main" : "dev") + " " + release.releaseNr + "/" + release.svn);- prop.put("candeploy_availreleases_" + relcount + "_url", release.url.toString());+ for(yacyRelease release : remoteDevReleases) {+ prop.put("candeploy_availreleases_" + relcount + "_name", ((release.isMainRelease()) ? "main" : "dev") + " " + release.getReleaseNr() + "/" + release.getSvn());+ prop.put("candeploy_availreleases_" + relcount + "_url", release.getUrl().toString());+ prop.put("candeploy_availreleases_" + relcount + "_signatures", (release.getPublicKey()!=null?"1":"0"));prop.put("candeploy_availreleases_" + relcount + "_selected", (release == dflt) ? "1" : "0");relcount++;}@@ -216,6 +222,7 @@ public class ConfigUpdate_p {prop.put("candeploy_lastdownload_time", new Date(sb.getConfigLong("update.time.download", 0)).toString());prop.put("candeploy_lastdeploy", (sb.getConfigLong("update.time.deploy", 0) == 0) ? "0" : "1");prop.put("candeploy_lastdeploy_time", new Date(sb.getConfigLong("update.time.deploy", 0)).toString());+ prop.put("candeploy_onlySignedFiles", (sb.getConfig("update.onlySignedFiles", "1").equals("1")) ? "1" : "0");/*if ((adminaccess) && (yacyVersion.latestRelease >= (thisVersion+0.01))) { // only new Versions(not new SVN)diff --git a/htroot/Network.java b/htroot/Network.javaindex e208a5bcf..62a8c08f7 100644--- a/htroot/Network.java+++ b/htroot/Network.java@@ -48,6 +48,7 @@ import de.anomic.yacy.yacyClient;import de.anomic.yacy.yacyNewsPool;import de.anomic.yacy.yacyNewsRecord;import de.anomic.yacy.yacySeed;+import de.anomic.yacy.yacyRelease;import de.anomic.yacy.yacyVersion;public class Network {@@ -418,7 +419,7 @@ public class Network {final String peertags = serverCodings.set2string(seed.getPeerTags(), ",", false);prop.putHTML(STR_TABLE_LIST + conCount + "_dhtreceive_peertags", ((peertags == null) || (peertags.length() == 0)) ? "no tags given" : ("tags = " + peertags));}- prop.putHTML(STR_TABLE_LIST + conCount + "_version", yacyVersion.combined2prettyVersion(seed.get(yacySeed.VERSION, "0.1"), shortname));+ prop.putHTML(STR_TABLE_LIST + conCount + "_version", yacyRelease.combined2prettyVersion(seed.get(yacySeed.VERSION, "0.1"), shortname));prop.putNum(STR_TABLE_LIST + conCount + "_lastSeen", /*seed.getLastSeenString() + " " +*/ lastseen);prop.put(STR_TABLE_LIST + conCount + "_utc", seed.get(yacySeed.UTC, "-"));prop.putHTML(STR_TABLE_LIST + conCount + "_uptime", DateFormatter.formatInterval(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, "0"))));diff --git a/htroot/Steering.java b/htroot/Steering.javaindex 785267c4c..af60c9494 100644--- a/htroot/Steering.java+++ b/htroot/Steering.java@@ -33,6 +33,7 @@ import de.anomic.http.httpRequestHeader;import de.anomic.plasma.plasmaSwitchboard;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;+import de.anomic.yacy.yacyRelease;import de.anomic.yacy.yacyVersion;public class Steering {@@ -59,7 +60,7 @@ public class Steering {}if (post.containsKey("restart")) {- yacyVersion.restart();+ yacyRelease.restart();prop.put("info", "4");return prop;@@ -70,7 +71,7 @@ public class Steering {final String releaseFileName = post.get("releaseinstall", "");final File releaseFile = new File(sb.getRootPath(), "DATA/RELEASE/".replace("/", File.separator) + releaseFileName);if ((!devenvironment) && (releaseFile.length() > 0) && (releaseFile.exists())) {- yacyVersion.deployRelease(releaseFile);+ yacyRelease.deployRelease(releaseFile);}prop.put("info", "5");prop.putHTML("info_release", releaseFileName);diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex 8dcd7f5c7..ec3b6b68f 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -182,6 +182,7 @@ import de.anomic.yacy.yacySeed;import de.anomic.yacy.Tray;import de.anomic.yacy.yacyURL;import de.anomic.yacy.yacyUpdateLocation;+import de.anomic.yacy.yacyRelease;import de.anomic.yacy.yacyVersion;import de.anomic.yacy.dht.Dispatcher;import de.anomic.yacy.dht.PeerSelection;@@ -736,7 +737,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.e.printStackTrace();}yacyUpdateLocation updateLocation = new yacyUpdateLocation(locationURL, publicKey);- yacyVersion.latestReleaseLocations.add(updateLocation);+ yacyRelease.latestReleaseLocations.add(updateLocation);i++;}} catch (NoSuchAlgorithmException e1) {@@ -1498,10 +1499,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// check if update is available and// if auto-update is activated perform an automatic installation and restart- final yacyVersion updateVersion = yacyVersion.rulebasedUpdateInfo(false);+ final yacyRelease updateVersion = yacyRelease.rulebasedUpdateInfo(false);if (updateVersion != null) {// there is a version that is more recent. Load it and re-start with it- log.logInfo("AUTO-UPDATE: downloading more recent release " + updateVersion.url);+ log.logInfo("AUTO-UPDATE: downloading more recent release " + updateVersion.getUrl());final File downloaded = updateVersion.downloadRelease();final boolean devenvironment = yacyVersion.combined2prettyVersion(sb.getConfig("version","0.1")).startsWith("dev");if (devenvironment) {@@ -1509,7 +1510,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.} else if ((downloaded == null) || (!downloaded.exists()) || (downloaded.length() == 0)) {log.logInfo("AUTO-UPDATE: omiting update because download failed (file cannot be found, is too small or signature is bad)");} else {- yacyVersion.deployRelease(downloaded);+ yacyRelease.deployRelease(downloaded);terminate(5000);log.logInfo("AUTO-UPDATE: deploy and restart initiated");}diff --git a/source/de/anomic/yacy/yacyRelease.java b/source/de/anomic/yacy/yacyRelease.javanew file mode 100644index 000000000..ba6177bd6--- /dev/null+++ b/source/de/anomic/yacy/yacyRelease.java@@ -0,0 +1,636 @@+// yacyVersion.java+// ----------------+// (C) 2007 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 27.04.2007 on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2009-04-17 16:52:42 +0200 (Fr, 17. Apr 2009) $+// $LastChangedRevision: 5828 $+// $LastChangedBy: f1ori $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.yacy;++import java.io.BufferedInputStream;+import java.io.BufferedOutputStream;+import java.io.File;+import java.io.FileInputStream;+import java.io.FileOutputStream;+import java.io.IOException;+import java.io.UnsupportedEncodingException;+import java.security.InvalidKeyException;+import java.security.NoSuchAlgorithmException;+import java.security.PublicKey;+import java.security.SignatureException;+import java.util.ArrayList;+import java.util.HashMap;+import java.util.Map;+import java.util.SortedSet;+import java.util.TreeSet;++import de.anomic.crawler.HTTPLoader;+import de.anomic.htmlFilter.htmlFilterContentScraper;+import de.anomic.http.httpClient;+import de.anomic.http.httpResponse;+import de.anomic.http.httpResponseHeader;+import de.anomic.http.httpRequestHeader;+import de.anomic.kelondro.order.Base64Order;+import de.anomic.kelondro.util.Log;+import de.anomic.kelondro.util.FileUtils;+import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.server.serverCharBuffer;+import de.anomic.server.serverCore;+import de.anomic.server.serverSystem;+import de.anomic.tools.CryptoLib;+import de.anomic.tools.SignatureOutputStream;+import de.anomic.tools.tarTools;++public final class yacyRelease extends yacyVersion {++ // information about latest release, retrieved from download pages+ // this static information should be overwritten by network-specific locations+ // for details see defaults/yacy.network.freeworld.unit+ private static HashMap<yacyUpdateLocation, DevAndMainVersions> latestReleases = new HashMap<yacyUpdateLocation, DevAndMainVersions>();+ public final static ArrayList<yacyUpdateLocation> latestReleaseLocations = new ArrayList<yacyUpdateLocation>(); // will be initialized with value in defaults/yacy.network.freeworld.unit++ private yacyURL url;+ private File releaseFile;++ private PublicKey publicKey;++ public yacyRelease(final yacyURL url) {+ super(url.getFileName());+ this.url = url;+ }++ public yacyRelease(final yacyURL url, PublicKey publicKey) {+ this(url);+ this.publicKey = publicKey;+ }++ public yacyRelease(final File releaseFile) {+ super(releaseFile.getName());+ this.releaseFile = releaseFile;+ }++ public yacyURL getUrl() {+ return url;+ }++ public static final yacyRelease rulebasedUpdateInfo(final boolean manual) {+ // according to update properties, decide if we should retrieve update information+ // if true, the release that can be obtained is returned.+ // if false, null is returned+ final plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();++ // check if update process allows update retrieve+ final String process = sb.getConfig("update.process", "manual");+ if ((!manual) && (!process.equals("auto"))) {+ yacyCore.log.logInfo("rulebasedUpdateInfo: not an automatic update selected");+ return null; // no, its a manual or guided process+ }++ // check if the last retrieve time is a minimum time ago+ final long cycle = Math.max(1, sb.getConfigLong("update.cycle", 168)) * 60 * 60 * 1000; // update.cycle is hours+ final long timeLookup = sb.getConfigLong("update.time.lookup", System.currentTimeMillis());+ if ((!manual) && (timeLookup + cycle > System.currentTimeMillis())) {+ yacyCore.log.logInfo("rulebasedUpdateInfo: too early for a lookup for a new release (timeLookup = " + timeLookup + ", cycle = " + cycle + ", now = " + System.currentTimeMillis() + ")");+ return null; // no we have recently made a lookup+ }++ // check if we know that there is a release that is more recent than that which we are using+ final DevAndMainVersions releases = yacyRelease.allReleases(true, sb.getConfig("update.onlySignedFiles", "1").equals("1"));+ final yacyRelease latestmain = (releases.main.size() == 0) ? null : releases.main.last();+ final yacyRelease latestdev = (releases.dev.size() == 0) ? null : releases.dev.last();+ final String concept = sb.getConfig("update.concept", "any");+ String blacklist = sb.getConfig("update.blacklist", "...[123]");+ if (blacklist.equals("....[123]")) {+ // patch the blacklist because of a release strategy change from 0.7 and up+ blacklist = "...[123]";+ sb.setConfig("update.blacklist", blacklist);+ }++ if ((manual) || (concept.equals("any"))) {+ // return a dev-release or a main-release+ if ((latestdev != null) &&+ ((latestmain == null) || (latestdev.compareTo(latestmain) > 0)) &&+ (!(Float.toString(latestdev.getReleaseNr()).matches(blacklist)))) {+ // consider a dev-release+ if (latestdev.compareTo(thisVersion()) <= 0) {+ yacyCore.log.logInfo(+ "rulebasedUpdateInfo: latest dev " + latestdev.getName() ++ " is not more recent than installed release " + thisVersion().getName());+ return null;+ }+ return latestdev;+ }+ if (latestmain != null) {+ // consider a main release+ if ((Float.toString(latestmain.getReleaseNr()).matches(blacklist))) {+ yacyCore.log.logInfo(+ "rulebasedUpdateInfo: latest dev " + (latestdev == null ? "null" : latestdev.getName()) ++ " matches with blacklist '" + blacklist + "'");+ return null;+ }+ if (latestmain.compareTo(thisVersion()) <= 0) {+ yacyCore.log.logInfo(+ "rulebasedUpdateInfo: latest main " + latestmain.getName() ++ " is not more recent than installed release (1) " + thisVersion().getName());+ return null;+ }+ return latestmain;+ }+ }+ if ((concept.equals("main")) && (latestmain != null)) {+ // return a main-release+ if ((Float.toString(latestmain.getReleaseNr()).matches(blacklist))) {+ yacyCore.log.logInfo(+ "rulebasedUpdateInfo: latest main " + latestmain.getName() ++ " matches with blacklist'" + blacklist + "'");+ return null;+ }+ if (latestmain.compareTo(thisVersion()) <= 0) {+ yacyCore.log.logInfo(+ "rulebasedUpdateInfo: latest main " + latestmain.getName() ++ " is not more recent than installed release (2) " + thisVersion().getName());+ return null;+ }+ return latestmain;+ }+ yacyCore.log.logInfo("rulebasedUpdateInfo: failed to find more recent release");+ return null;+ }++ public static DevAndMainVersions allReleases(final boolean force, final boolean onlySigned) {+ // join the release infos+ final TreeSet<yacyRelease> alldev = new TreeSet<yacyRelease>();+ final TreeSet<yacyRelease> allmain = new TreeSet<yacyRelease>();+ for (yacyUpdateLocation updateLocation : latestReleaseLocations) {+ if(!onlySigned || updateLocation.getPublicKey() != null) {+ DevAndMainVersions versions = getReleases(updateLocation, force);+ if ((versions != null) && (versions.dev != null)) alldev.addAll(versions.dev);+ if ((versions != null) && (versions.main != null)) allmain.addAll(versions.main);+ }+ }+ return new DevAndMainVersions(alldev, allmain);+ }++ /**+ * get all Releases from update location using cache+ * @param location Update location+ * @param force when true, don't fetch from cache+ * @return+ */+ private static DevAndMainVersions getReleases(final yacyUpdateLocation location, final boolean force) {+ // get release info from a Internet resource+ DevAndMainVersions locLatestRelease = latestReleases.get(location);+ if (force ||+ (locLatestRelease == null) /*||+ ((latestRelease[0].size() == 0) &&+ (latestRelease[1].size() == 0) &&+ (latestRelease[2].size() == 0) &&+ (latestRelease[3].size() == 0) )*/) {+ locLatestRelease = allReleaseFrom(location);+ latestReleases.put(location, locLatestRelease);+ }+ return locLatestRelease;+ }++ /**+ * get all releases from update location+ * @param location+ * @return+ */+ private static DevAndMainVersions allReleaseFrom(yacyUpdateLocation location) {+ // retrieves the latest info about releases+ // this is done by contacting a release location,+ // parsing the content and filtering+parsing links+ // returns the version info if successful, null otherwise+ htmlFilterContentScraper scraper;+ try {+ scraper = htmlFilterContentScraper.parseResource(location.getLocationURL());+ } catch (final IOException e) {+ return null;+ }++ // analyse links in scraper resource, and find link to latest release in it+ final Map<yacyURL, String> anchors = scraper.getAnchors(); // a url (String) / name (String) relation+ final TreeSet<yacyRelease> mainReleases = new TreeSet<yacyRelease>();+ final TreeSet<yacyRelease> devReleases = new TreeSet<yacyRelease>();+ for(yacyURL url : anchors.keySet()) {+ try {+ yacyRelease release = new yacyRelease(url, location.getPublicKey());+ //System.out.println("r " + release.toAnchor());+ if(release.isMainRelease()) {+ mainReleases.add(release);+ } else {+ devReleases.add(release);+ }+ } catch (final RuntimeException e) {+ // the release string was not well-formed.+ // that might have been another link+ // just don't care+ continue;+ }+ }+ plasmaSwitchboard.getSwitchboard().setConfig("update.time.lookup", System.currentTimeMillis());+ return new DevAndMainVersions(devReleases, mainReleases);+ }++ public static final class DevAndMainVersions {+ public TreeSet<yacyRelease> dev, main;+ public DevAndMainVersions(final TreeSet<yacyRelease> dev, final TreeSet<yacyRelease> main) {+ this.dev = dev;+ this.main = main;+ }+ }+++ /**+ * <p>download this release and if public key is know, download signature and check it.+ * <p>The signature is named $releaseurl.sig and contains the base64 encoded signature+ * (@see de.anomic.tools.CryptoLib)+ * @return file object of release file, null in case of failure+ */+ public File downloadRelease() {+ final File storagePath = plasmaSwitchboard.getSwitchboard().releasePath;+ File download = null;+ // setup httpClient+ final httpRequestHeader reqHeader = new httpRequestHeader();+ reqHeader.put(httpResponseHeader.USER_AGENT, HTTPLoader.yacyUserAgent);++ httpResponse res = null;+ final String name = this.getUrl().getFileName();+ byte[] signatureBytes = null;+ // download signature first, if public key is available+ if(this.publicKey != null) {+ final byte[] signatureData = httpClient.wget(this.getUrl().toString() + ".sig", reqHeader, 6000);+ if(signatureData == null) {+ Log.logSevere("yacyVersion", "download of signature " + this.getUrl().toString() + " failed");+ return null;+ }+ try {+ signatureBytes = Base64Order.standardCoder.decode(new String(signatureData, "UTF8").trim(), "decode signature");+ } catch (UnsupportedEncodingException e) {+ Log.logSevere("yacyVersion", "download of signature " + this.getUrl().toString() + " failed: unsupported encoding");+ return null;+ }+ }+ try {+ final httpClient client = new httpClient(120000, reqHeader);+ res = client.GET(this.getUrl().toString());++ final boolean unzipped = res.getResponseHeader().gzip() && (res.getResponseHeader().mime().toLowerCase().equals("application/x-tar")); // if true, then the httpc has unzipped the file+ if ((unzipped) && (name.endsWith(".tar.gz"))) {+ download = new File(storagePath, name.substring(0, name.length() - 3));+ } else {+ download = new File(storagePath, name);+ }+ if(this.publicKey != null) {+ // copy to file and check signature+ SignatureOutputStream verifyOutput = null;+ try {+ verifyOutput = new SignatureOutputStream(new FileOutputStream(download), CryptoLib.signAlgorithm, publicKey);+ FileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(verifyOutput));++ if(!verifyOutput.verify(signatureBytes)) {+ throw new IOException("Bad Signature!");+ }+ } catch (NoSuchAlgorithmException e) {+ throw new IOException("No such algorithm");+ } catch (SignatureException e) {+ throw new IOException("Signature exception");+ } finally {+ if(verifyOutput != null)+ verifyOutput.close();+ }+ // Save signature+ File signatureFile = new File(download.getAbsoluteFile() + ".sig");+ FileUtils.copy(Base64Order.standardCoder.encode(signatureBytes).getBytes("UTF-8"), signatureFile);+ if ((!signatureFile.exists()) || (signatureFile.length() == 0)) throw new IOException("create signature file failed");+ } else {+ // just copy into file+ FileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(new FileOutputStream(download)));+ }+ if ((!download.exists()) || (download.length() == 0)) throw new IOException("wget of url " + this.getUrl() + " failed");+ } catch (final IOException e) {+ // Saving file failed, abort download+ res.abort();+ Log.logSevere("yacyVersion", "download of " + this.getName() + " failed: " + e.getMessage());+ if (download != null && download.exists()) {+ FileUtils.deletedelete(download);+ if (download.exists())+ Log.logWarning("yacyVersion", "could not delete file "+ download);+ }+ download = null;+ } finally {+ if (res != null) {+ // release connection+ res.closeStream();+ }+ }+ this.releaseFile = download;+ plasmaSwitchboard.getSwitchboard().setConfig("update.time.download", System.currentTimeMillis());+ return this.releaseFile;+ }++ public boolean checkSignature() {+ if(releaseFile != null) {+ try {+ serverCharBuffer signBuffer;+ signBuffer = new serverCharBuffer(getSignatureFile());+ byte[] signByteBuffer = Base64Order.standardCoder.decode(+ signBuffer.toString().trim(), "Signature");+ CryptoLib cl = new CryptoLib();+ for(yacyUpdateLocation updateLocation : latestReleaseLocations) {+ try {+ if(cl.verifySignature(updateLocation.getPublicKey(),+ new FileInputStream(releaseFile), signByteBuffer)) {+ return true;+ }+ } catch (InvalidKeyException e) {+ } catch (SignatureException e) {+ }+ }+ } catch (IOException e1) {+ } catch (NoSuchAlgorithmException e) {+ }++ }+ return false;+ }++ /**+ * restart yacy by stopping yacy and previously running a batch+ * script, which waits until yacy is terminated and starts it again+ */+ public static void restart() {+ final plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();+ final String apphome = sb.getRootPath().toString();++ if (serverSystem.isWindows) {+ final File startType = new File(sb.getRootPath(), "DATA/yacy.noconsole".replace("/", File.separator));+ String starterFile = "startYACY_debug.bat";+ if (startType.exists()) starterFile = "startYACY.bat"; // startType noconsole++ try{+ Log.logInfo("RESTART", "INITIATED");+ final String script =+ "@echo off" + serverCore.LF_STRING ++ "title YaCy restarter" + serverCore.LF_STRING ++ "set loading=YACY RESTARTER" + serverCore.LF_STRING ++ "echo %loading%" + serverCore.LF_STRING ++ "cd \"" + apphome + "/DATA/RELEASE/".replace("/", File.separator) + "\"" + serverCore.LF_STRING ++ ":WAIT" + serverCore.LF_STRING ++ "set loading=%loading%." + serverCore.LF_STRING ++ "cls" + serverCore.LF_STRING ++ "echo %loading%" + serverCore.LF_STRING ++ "ping -n 2 127.0.0.1 >nul" + serverCore.LF_STRING ++ "IF exist ..\\yacy.running goto WAIT" + serverCore.LF_STRING ++ "cd \"" + apphome + "\"" + serverCore.LF_STRING ++ "start /MIN CMD /C " + starterFile + serverCore.LF_STRING;+ final File scriptFile = new File(sb.getRootPath(), "DATA/RELEASE/restart.bat".replace("/", File.separator));+ serverSystem.deployScript(scriptFile, script);+ Log.logInfo("RESTART", "wrote restart-script to " + scriptFile.getAbsolutePath());+ serverSystem.execAsynchronous(scriptFile);+ Log.logInfo("RESTART", "script is running");+ sb.terminate(5000);+ } catch (final IOException e) {+ Log.logSevere("RESTART", "restart failed", e);+ }++ // create yacy.restart file which is used in Windows startscript+ /* final File yacyRestart = new File(sb.getRootPath(), "DATA/yacy.restart");+ if (!yacyRestart.exists()) {+ try {+ yacyRestart.createNewFile();+ plasmaSwitchboard.getSwitchboard().terminate(5000);+ } catch (IOException e) {+ serverLog.logSevere("SHUTDOWN", "restart failed", e);+ }+ }*/++ }++ if (serverSystem.canExecUnix) {+ // start a re-start daemon+ try {+ Log.logInfo("RESTART", "INITIATED");+ final String script =+ "#!/bin/sh" + serverCore.LF_STRING ++ "cd " + sb.getRootPath() + "/DATA/RELEASE/" + serverCore.LF_STRING ++ "while [ -f ../yacy.running ]; do" + serverCore.LF_STRING ++ "sleep 1" + serverCore.LF_STRING ++ "done" + serverCore.LF_STRING ++ "cd ../../" + serverCore.LF_STRING ++ "nohup ./startYACY.sh > /dev/null" + serverCore.LF_STRING;+ final File scriptFile = new File(sb.getRootPath(), "DATA/RELEASE/restart.sh");+ serverSystem.deployScript(scriptFile, script);+ Log.logInfo("RESTART", "wrote restart-script to " + scriptFile.getAbsolutePath());+ serverSystem.execAsynchronous(scriptFile);+ Log.logInfo("RESTART", "script is running");+ sb.terminate(5000);+ } catch (final IOException e) {+ Log.logSevere("RESTART", "restart failed", e);+ }+ }+ }++ /**+ * stop yacy and run a batch script, applies a new release and restarts yacy+ * @param releaseFile+ */+ public static void deployRelease(final File releaseFile) {+ //byte[] script = ("cd " + plasmaSwitchboard.getSwitchboard().getRootPath() + ";while [ -e ../yacy.running ]; do sleep 1;done;tar xfz " + release + ";cp -Rf yacy/* ../../;rm -Rf yacy;cd ../../;startYACY.sh").getBytes();+ try {+ final plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();+ final String apphome = sb.getRootPath().toString();+ Log.logInfo("UPDATE", "INITIATED");+ try{+ tarTools.unTar(tarTools.getInputStream(releaseFile), sb.getRootPath() + "/DATA/RELEASE/".replace("/", File.separator));+ } catch (final Exception e){+ Log.logSevere("UNTAR", "failed", e);+ }+ String script = null;+ String scriptFileName = null;+ if(serverSystem.isWindows){+ final File startType = new File(sb.getRootPath(), "DATA/yacy.noconsole".replace("/", File.separator));+ String starterFile = "startYACY_debug.bat";+ if (startType.exists()) starterFile = "startYACY.bat"; // startType noconsole+ script =+ "@echo off" + serverCore.LF_STRING ++ "title YaCy updater" + serverCore.LF_STRING ++ "set loading=YACY UPDATER" + serverCore.LF_STRING ++ "echo %loading%" + serverCore.LF_STRING ++ "cd \"" + apphome + "/DATA/RELEASE/".replace("/", File.separator) + "\"" + serverCore.LF_STRING +++ ":WAIT" + serverCore.LF_STRING ++ "set loading=%loading%." + serverCore.LF_STRING ++ "cls" + serverCore.LF_STRING ++ "echo %loading%" + serverCore.LF_STRING ++ "ping -n 2 127.0.0.1 >nul" + serverCore.LF_STRING ++ "IF exist ..\\yacy.running goto WAIT" + serverCore.LF_STRING ++ "IF not exist yacy goto NODATA" + serverCore.LF_STRING +++ "cd yacy" + serverCore.LF_STRING ++ "xcopy *.* \"" + apphome + "\" /E /Y >nul" + serverCore.LF_STRING ++ // /E - all subdirectories+ // /Y - don't ask+ "cd .." + serverCore.LF_STRING ++ "rd yacy /S /Q" + serverCore.LF_STRING ++ // /S delete tree+ // /Q don't ask+ "goto END" + serverCore.LF_STRING +++ ":NODATA" + serverCore.LF_STRING ++ "echo YACY UPDATER ERROR: NO UPDATE SOURCE FILES ON FILESYSTEM" + serverCore.LF_STRING ++ "pause" + serverCore.LF_STRING +++ ":END" + serverCore.LF_STRING ++ "cd \"" + apphome + "\"" + serverCore.LF_STRING ++ "start /MIN CMD /C " + starterFile + serverCore.LF_STRING;+ scriptFileName = "update.bat";+ } else { // unix/linux+ script =+ "#!/bin/sh" + serverCore.LF_STRING ++ "cd " + sb.getRootPath() + "/DATA/RELEASE/" + serverCore.LF_STRING ++ /* ((releaseFile.getName().endsWith(".gz")) ?+ // test gz-file for integrity and tar xfz then+ ("if gunzip -t " + releaseFile.getAbsolutePath() + serverCore.LF_STRING ++ "then" + serverCore.LF_STRING ++ "gunzip -c " + releaseFile.getAbsolutePath() + " | tar xf -" + serverCore.LF_STRING) :+ // just tar xf the file, no integrity test possible?+ ("tar xf " + releaseFile.getAbsolutePath() + serverCore.LF_STRING)+ ) +*/+ "while [ -f ../yacy.running ]; do" + serverCore.LF_STRING ++ "sleep 1" + serverCore.LF_STRING ++ "done" + serverCore.LF_STRING ++ "cp -Rf yacy/* " + apphome + serverCore.LF_STRING ++ "rm -Rf yacy" + serverCore.LF_STRING ++ /* ((releaseFile.getName().endsWith(".gz")) ?+ // else-case of gunzip -t test: if failed, just restart+ ("else" + serverCore.LF_STRING ++ "while [ -f ../yacy.running ]; do" + serverCore.LF_STRING ++ "sleep 1" + serverCore.LF_STRING ++ "done" + serverCore.LF_STRING ++ "fi" + serverCore.LF_STRING) :+ // in case that we did not made the integrity test, there is no else case+ ""+ ) +*/+ "cd " + apphome + serverCore.LF_STRING ++ "nohup ./startYACY.sh > /dev/null" + serverCore.LF_STRING;+ scriptFileName = "update.sh";+ }+ final File scriptFile = new File(sb.getRootPath(), "DATA/RELEASE/".replace("/", File.separator) + scriptFileName);+ serverSystem.deployScript(scriptFile, script);+ Log.logInfo("UPDATE", "wrote update-script to " + scriptFile.getAbsolutePath());+ serverSystem.execAsynchronous(scriptFile);+ Log.logInfo("UPDATE", "script is running");+ sb.setConfig("update.time.deploy", System.currentTimeMillis());+ sb.terminate(5000);+ } catch (final IOException e) {+ Log.logSevere("UPDATE", "update failed", e);+ }+ }++ public static void main(final String[] args) {+ System.out.println(thisVersion());+ final float base = (float) 0.53;+ final String blacklist = "....[123]";+ String test;+ for (int i = 0; i < 20; i++) {+ test = Float.toString(base + (((float) i) / 1000));+ System.out.println(test + " is " + ((test.matches(blacklist)) ? "blacklisted" : " not blacklisted"));+ }+ }++ /**+ * keep only releases of last month (minimum latest and 1 main (maybe the same))+ *+ * @param filesPath where all downloaded files reside+ * @param deleteAfterDays+ */+ public static void deleteOldDownloads(final File filesPath, final int deleteAfterDays) {+ // list downloaded releases+ yacyVersion release;+ final String[] downloaded = filesPath.list();++ // parse all filenames and put them in a sorted set+ final SortedSet<yacyVersion> downloadedreleases = new TreeSet<yacyVersion>();+ for (int j = 0; j < downloaded.length; j++) {+ try {+ release = new yacyVersion(downloaded[j]);+ downloadedreleases.add(release);+ } catch (final RuntimeException e) {+ // not a valid release+ }+ }++ // if we have some files+ if(downloadedreleases.size() > 0) {+ Log.logFine("STARTUP", "deleting downloaded releases older than "+ deleteAfterDays +" days");++ // keep latest version+ final yacyVersion latest = downloadedreleases.last();+ downloadedreleases.remove(latest);+ // if latest is a developer release, we also keep a main release+ final boolean keepMain = !latest.isMainRelease();++ // remove old files+ final long now = System.currentTimeMillis();+ final long deleteAfterMillis = deleteAfterDays * 24L * 60 * 60000;++ String lastMain = null;+ String filename;+ for (final yacyVersion aVersion : downloadedreleases) {+ filename = aVersion.getName();+ if (keepMain && aVersion.isMainRelease()) {+ // keep this one, delete last remembered main release file+ if (lastMain != null) {+ filename = lastMain;+ }+ lastMain = aVersion.getName();+ }++ // check file age+ final File downloadedFile = new File(filesPath + File.separator + filename);+ if (now - downloadedFile.lastModified() > deleteAfterMillis) {+ // delete file+ FileUtils.deletedelete(downloadedFile);+ if (downloadedFile.exists()) {+ Log.logWarning("STARTUP", "cannot delete old release " + downloadedFile.getAbsolutePath());+ }+ }+ }+ }+ }++ public File getReleaseFile() {+ return releaseFile;+ }++ public File getSignatureFile() {+ return new File(releaseFile.getAbsoluteFile() + ".sig");+ }++ public PublicKey getPublicKey() {+ return publicKey;+ }++}diff --git a/source/de/anomic/yacy/yacyURL.java b/source/de/anomic/yacy/yacyURL.javaindex 50fa24540..d78cb29cf 100644--- a/source/de/anomic/yacy/yacyURL.java+++ b/source/de/anomic/yacy/yacyURL.java@@ -67,6 +67,10 @@ public class yacyURL implements Serializable {return (url == null) ? null : url.hash().substring(6);}+ public yacyURL(final String url) throws MalformedURLException {+ this(url, null);+ }+public yacyURL(final String url, final String hash) throws MalformedURLException {if (url == null) throw new MalformedURLException("url string is null");diff --git a/source/de/anomic/yacy/yacyVersion.java b/source/de/anomic/yacy/yacyVersion.javaindex 1ccc90d6e..fbaf7a5d8 100644--- a/source/de/anomic/yacy/yacyVersion.java+++ b/source/de/anomic/yacy/yacyVersion.java@@ -1,121 +1,47 @@-// yacyVersion.java-// -----------------// (C) 2007 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany-// first published 27.04.2007 on http://yacy.net-//-// This is a part of YaCy, a peer-to-peer based web search engine-//-// $LastChangedDate$-// $LastChangedRevision$-// $LastChangedBy$-//-// LICENSE-//-// This program is free software; you can redistribute it and/or modify-// it under the terms of the GNU General Public License as published by-// the Free Software Foundation; either version 2 of the License, or-// (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU General Public License for more details.-//-// You should have received a copy of the GNU General Public License-// along with this program; if not, write to the Free Software-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-package de.anomic.yacy;-import java.io.BufferedInputStream;-import java.io.BufferedOutputStream;import java.io.File;-import java.io.FileOutputStream;-import java.io.IOException;-import java.io.UnsupportedEncodingException;-import java.security.NoSuchAlgorithmException;-import java.security.PublicKey;-import java.security.SignatureException;-import java.util.ArrayList;import java.util.Comparator;-import java.util.HashMap;-import java.util.Map;-import java.util.SortedSet;-import java.util.TreeSet;import java.util.regex.Matcher;import java.util.regex.Pattern;-import de.anomic.crawler.HTTPLoader;-import de.anomic.htmlFilter.htmlFilterContentScraper;-import de.anomic.http.httpClient;-import de.anomic.http.httpResponse;-import de.anomic.http.httpResponseHeader;-import de.anomic.http.httpRequestHeader;-import de.anomic.kelondro.order.Base64Order;import de.anomic.kelondro.util.Log;-import de.anomic.kelondro.util.FileUtils;import de.anomic.plasma.plasmaSwitchboard;-import de.anomic.server.serverCore;-import de.anomic.server.serverSystem;-import de.anomic.tools.CryptoLib;-import de.anomic.tools.SignatureOutputStream;-import de.anomic.tools.tarTools;-public final class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVersion> {-- // general release info+public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVersion> {+public static final float YACY_SUPPORTS_PORT_FORWARDING = (float) 0.383;public static final float YACY_SUPPORTS_GZIP_POST_REQUESTS_CHUNKED = (float) 0.58204761;public static final float YACY_ACCEPTS_RANKING_TRANSMISSION = (float) 0.414;public static final float YACY_HANDLES_COLLECTION_INDEX = (float) 0.486;public static final float YACY_POVIDES_REMOTECRAWL_LISTS = (float) 0.550;public static final float YACY_STANDARDREL_IS_PRO = (float) 0.557;-- // information about latest release, retrieved by other peers release version- public static double latestRelease = 0.1; // this value is overwritten when a peer with later version appears-- // information about latest release, retrieved from download pages- // this static information should be overwritten by network-specific locations- // for details see defaults/yacy.network.freeworld.unit- private static HashMap<yacyUpdateLocation, DevAndMainVersions> latestReleases = new HashMap<yacyUpdateLocation, DevAndMainVersions>();- public final static ArrayList<yacyUpdateLocation> latestReleaseLocations = new ArrayList<yacyUpdateLocation>(); // will be initialized with value in defaults/yacy.network.freeworld.unit-- // private static release info about this release; is generated only once and can be retrieved by thisVersion()private static yacyVersion thisVersion = null;- // class variables- public float releaseNr;- public String dateStamp;- public int svn;- public boolean mainRelease;- public yacyURL url;- public String name;- private File releaseFile;- private PublicKey publicKey;-- public yacyVersion(final yacyURL url) {- this(url.getFileName());- this.url = url;- }-- public yacyVersion(final yacyURL url, PublicKey publicKey) {- this(url.getFileName());- this.url = url;- this.publicKey = publicKey;- }-- public yacyVersion(final File releaseFile) {- this(releaseFile.getName());- this.releaseFile = releaseFile;- }-+ /**+ * information about latest release, retrieved by other peers release version,+ * this value is overwritten when a peer with later version appears*/+ public static double latestRelease = 0.1; //++ private float releaseNr;+ private String dateStamp;+ private int svn;+ private boolean mainRelease;++ private String name;++ /**+ * parse a release file name+ * <p>the have the following form:+ * <ul>+ * <li>yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz</li>+ * <li>yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz</li>+ * </ul>+ * i.e. yacy_v0.51_20070321_3501.tar.gz+ * @param release+ */public yacyVersion(String release) {- // parse a release file name- // the have the following form:- // yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz- // yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz- // i.e. yacy_v0.51_20070321_3501.tar.gz- this.url = null;+this.name = release;if ((release == null) || (!((release.endsWith(".tar.gz") || (release.endsWith(".tar")))))) {throw new RuntimeException("release file name '" + release + "' is not valid, no tar.gz");@@ -142,10 +68,10 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya} catch (final NumberFormatException e) {throw new RuntimeException("release file name '" + release + "' is not valid, '" + comp[0] + "' should be a float number");}- this.mainRelease = ((int) (this.releaseNr * 100)) % 10 == 0;+ this.mainRelease = ((int) (this.getReleaseNr() * 100)) % 10 == 0;//System.out.println("Release version " + this.releaseNr + " is " + ((this.mainRelease) ? "main" : "std"));this.dateStamp = comp[1];- if (this.dateStamp.length() != 8) {+ if (this.getDateStamp().length() != 8) {throw new RuntimeException("release file name '" + release + "' is not valid, '" + comp[1] + "' should be a 8-digit date string");}try {@@ -155,46 +81,8 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya}// finished! we parsed a relase string}-- public static final class DevAndMainVersions {- public TreeSet<yacyVersion> dev, main;- public DevAndMainVersions(final TreeSet<yacyVersion> dev, final TreeSet<yacyVersion> main) {- this.dev = dev;- this.main = main;- }- }-- public int compareTo(final yacyVersion obj) {- // returns 0 if this object is equal to the obj, -1 if this is smaller than obj and 1 if this is greater than obj- return compare(this, obj);- }-- public int compare(final yacyVersion v0, final yacyVersion v1) {- // compare-operator for two yacyVersion objects- // must be implemented to make it possible to put this object into- // a ordered structure, like TreeSet or TreeMap- return (Integer.valueOf(v0.svn)).compareTo(Integer.valueOf(v1.svn));- }-- public boolean equals(final Object obj) {- if(obj instanceof yacyVersion) {- final yacyVersion v = (yacyVersion) obj;- return (this.svn == v.svn) && (this.url.toNormalform(true, true).equals(v.url.toNormalform(true, true)));- }- return false;- }-- public int hashCode() {- return this.url.toNormalform(true, true).hashCode();- }-- public String toAnchor() {- // generates an anchor string that can be used to embed in an html for direct download- return "<a href=" + this.url.toNormalform(true, true) + ">YaCy " + ((this.mainRelease) ? "main release" : "dev release") + " v" + this.releaseNr + ", SVN " + this.svn + "</a>";- }-- // static methods:+public static final yacyVersion thisVersion() {// construct a virtual release name for this releaseif (thisVersion == null) {@@ -209,425 +97,36 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya}return thisVersion;}-- public static final yacyVersion rulebasedUpdateInfo(final boolean manual) {- // according to update properties, decide if we should retrieve update information- // if true, the release that can be obtained is returned.- // if false, null is returned- final plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();-- // check if update process allows update retrieve- final String process = sb.getConfig("update.process", "manual");- if ((!manual) && (!process.equals("auto"))) {- yacyCore.log.logInfo("rulebasedUpdateInfo: not an automatic update selected");- return null; // no, its a manual or guided process- }-- // check if the last retrieve time is a minimum time ago- final long cycle = Math.max(1, sb.getConfigLong("update.cycle", 168)) * 60 * 60 * 1000; // update.cycle is hours- final long timeLookup = sb.getConfigLong("update.time.lookup", System.currentTimeMillis());- if ((!manual) && (timeLookup + cycle > System.currentTimeMillis())) {- yacyCore.log.logInfo("rulebasedUpdateInfo: too early for a lookup for a new release (timeLookup = " + timeLookup + ", cycle = " + cycle + ", now = " + System.currentTimeMillis() + ")");- return null; // no we have recently made a lookup- }-- // check if we know that there is a release that is more recent than that which we are using- final DevAndMainVersions releases = yacyVersion.allReleases(true);- final yacyVersion latestmain = (releases.main.size() == 0) ? null : releases.main.last();- final yacyVersion latestdev = (releases.dev.size() == 0) ? null : releases.dev.last();- final String concept = sb.getConfig("update.concept", "any");- String blacklist = sb.getConfig("update.blacklist", "...[123]");- if (blacklist.equals("....[123]")) {- // patch the blacklist because of a release strategy change from 0.7 and up- blacklist = "...[123]";- sb.setConfig("update.blacklist", blacklist);- }-- if ((manual) || (concept.equals("any"))) {- // return a dev-release or a main-release- if ((latestdev != null) &&- ((latestmain == null) || (latestdev.compareTo(latestmain) > 0)) &&- (!(Float.toString(latestdev.releaseNr).matches(blacklist)))) {- // consider a dev-release- if (latestdev.compareTo(thisVersion()) <= 0) {- yacyCore.log.logInfo(- "rulebasedUpdateInfo: latest dev " + latestdev.name +- " is not more recent than installed release " + thisVersion().name);- return null;- }- return latestdev;- }- if (latestmain != null) {- // consider a main release- if ((Float.toString(latestmain.releaseNr).matches(blacklist))) {- yacyCore.log.logInfo(- "rulebasedUpdateInfo: latest dev " + (latestdev == null ? "null" : latestdev.name) +- " matches with blacklist '" + blacklist + "'");- return null;- }- if (latestmain.compareTo(thisVersion()) <= 0) {- yacyCore.log.logInfo(- "rulebasedUpdateInfo: latest main " + latestmain.name +- " is not more recent than installed release (1) " + thisVersion().name);- return null;- }- return latestmain;- }- }- if ((concept.equals("main")) && (latestmain != null)) {- // return a main-release- if ((Float.toString(latestmain.releaseNr).matches(blacklist))) {- yacyCore.log.logInfo(- "rulebasedUpdateInfo: latest main " + latestmain.name +- " matches with blacklist'" + blacklist + "'");- return null;- }- if (latestmain.compareTo(thisVersion()) <= 0) {- yacyCore.log.logInfo(- "rulebasedUpdateInfo: latest main " + latestmain.name +- " is not more recent than installed release (2) " + thisVersion().name);- return null;- }- return latestmain;- }- yacyCore.log.logInfo("rulebasedUpdateInfo: failed to find more recent release");- return null;- }-- public static DevAndMainVersions allReleases(final boolean force) {- // join the release infos- final DevAndMainVersions[] a = new DevAndMainVersions[latestReleaseLocations.size()];- for (int j = 0; j < latestReleaseLocations.size(); j++) {- a[j] = getReleases(latestReleaseLocations.get(j), force);- }- final TreeSet<yacyVersion> alldev = new TreeSet<yacyVersion>();- final TreeSet<yacyVersion> allmain = new TreeSet<yacyVersion>();- for (int j = 0; j < a.length; j++) if ((a[j] != null) && (a[j].dev != null)) alldev.addAll(a[j].dev);- for (int j = 0; j < a.length; j++) if ((a[j] != null) && (a[j].main != null)) allmain.addAll(a[j].main);-- return new DevAndMainVersions(alldev, allmain);- }-- /**- * get all Releases from update location using cache- * @param location Update location- * @param force when true, don't fetch from cache- * @return- */- private static DevAndMainVersions getReleases(final yacyUpdateLocation location, final boolean force) {- // get release info from a Internet resource- DevAndMainVersions locLatestRelease = latestReleases.get(location);- if (force ||- (locLatestRelease == null) /*||- ((latestRelease[0].size() == 0) &&- (latestRelease[1].size() == 0) &&- (latestRelease[2].size() == 0) &&- (latestRelease[3].size() == 0) )*/) {- locLatestRelease = allReleaseFrom(location);- latestReleases.put(location, locLatestRelease);- }- return locLatestRelease;- }-+/**- * get all releases from update location- * @param location- * @return+ * returns 0 if this object is equal to the obj, -1 if this is smaller+ * than obj and 1 if this is greater than obj*/- private static DevAndMainVersions allReleaseFrom(yacyUpdateLocation location) {- // retrieves the latest info about releases- // this is done by contacting a release location,- // parsing the content and filtering+parsing links- // returns the version info if successful, null otherwise- htmlFilterContentScraper scraper;- try {- scraper = htmlFilterContentScraper.parseResource(location.getLocationURL());- } catch (final IOException e) {- return null;- }-- // analyse links in scraper resource, and find link to latest release in it- final Map<yacyURL, String> anchors = scraper.getAnchors(); // a url (String) / name (String) relation- final TreeSet<yacyVersion> mainReleases = new TreeSet<yacyVersion>();- final TreeSet<yacyVersion> devReleases = new TreeSet<yacyVersion>();- for(yacyURL url : anchors.keySet()) {- try {- yacyVersion release = new yacyVersion(url, location.getPublicKey());- //System.out.println("r " + release.toAnchor());- if(release.mainRelease) {- mainReleases.add(release);- } else {- devReleases.add(release);- }- } catch (final RuntimeException e) {- // the release string was not well-formed.- // that might have been another link- // just don't care- continue;- }- }- plasmaSwitchboard.getSwitchboard().setConfig("update.time.lookup", System.currentTimeMillis());- return new DevAndMainVersions(devReleases, mainReleases);+ public int compareTo(final yacyVersion obj) {+ return compare(this, obj);}-- /**- * <p>download this release and if public key is know, download signature and check it.- * <p>The signature is named $releaseurl.sig and contains the base64 encoded signature- * (@see de.anomic.tools.CryptoLib)- * @return file object of release file, null in case of failure- */- public File downloadRelease() {- final File storagePath = plasmaSwitchboard.getSwitchboard().releasePath;- File download = null;- // setup httpClient- final httpRequestHeader reqHeader = new httpRequestHeader();- reqHeader.put(httpResponseHeader.USER_AGENT, HTTPLoader.yacyUserAgent);-- httpResponse res = null;- final String name = this.url.getFileName();- byte[] signatureBytes = null;- // download signature first, if public key is available- if(this.publicKey != null) {- final byte[] signatureData = httpClient.wget(this.url.toString() + ".sig", reqHeader, 6000);- if(signatureData == null) {- Log.logSevere("yacyVersion", "download of signature " + this.url.toString() + " failed");- return null;- }- try {- signatureBytes = Base64Order.standardCoder.decode(new String(signatureData, "UTF8").trim(), "decode signature");- } catch (UnsupportedEncodingException e) {- Log.logSevere("yacyVersion", "download of signature " + this.url.toString() + " failed: unsupported encoding");- return null;- }- }- try {- final httpClient client = new httpClient(120000, reqHeader);- res = client.GET(this.url.toString());-- final boolean unzipped = res.getResponseHeader().gzip() && (res.getResponseHeader().mime().toLowerCase().equals("application/x-tar")); // if true, then the httpc has unzipped the file- if ((unzipped) && (name.endsWith(".tar.gz"))) {- download = new File(storagePath, name.substring(0, name.length() - 3));- } else {- download = new File(storagePath, name);- }- if(this.publicKey != null) {- // copy to file and check signature- SignatureOutputStream verifyOutput = null;- try {- verifyOutput = new SignatureOutputStream(new FileOutputStream(download), CryptoLib.signAlgorithm, publicKey);- FileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(verifyOutput));- if(!verifyOutput.verify(signatureBytes)) {- throw new IOException("Bad Signature!");- }- } catch (NoSuchAlgorithmException e) {- throw new IOException("No such algorithm");- } catch (SignatureException e) {- throw new IOException("Signature exception");- } finally {- if(verifyOutput != null)- verifyOutput.close();- }- } else {- // just copy into file- FileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(new FileOutputStream(download)));- }- if ((!download.exists()) || (download.length() == 0)) throw new IOException("wget of url " + this.url + " failed");- } catch (final IOException e) {- // Saving file failed, abort download- res.abort();- Log.logSevere("yacyVersion", "download of " + this.name + " failed: " + e.getMessage());- if (download != null && download.exists()) {- FileUtils.deletedelete(download);- if (download.exists())- Log.logWarning("yacyVersion", "could not delete file "+ download);- }- download = null;- } finally {- if (res != null) {- // release connection- res.closeStream();- }- }- this.releaseFile = ((download != null) && (download.exists())) ? download : null;- // check signature- plasmaSwitchboard.getSwitchboard().setConfig("update.time.download", System.currentTimeMillis());- return this.releaseFile;- }-/**- * restart yacy by stopping yacy and previously running a batch- * script, which waits until yacy is terminated and starts it again+ * compare-operator for two yacyVersion objects+ * must be implemented to make it possible to put this object into+ * a ordered structure, like TreeSet or TreeMap*/- public static void restart() {- final plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();- final String apphome = sb.getRootPath().toString();-- if (serverSystem.isWindows) {- final File startType = new File(sb.getRootPath(), "DATA/yacy.noconsole".replace("/", File.separator));- String starterFile = "startYACY_debug.bat";- if (startType.exists()) starterFile = "startYACY.bat"; // startType noconsole-- try{- Log.logInfo("RESTART", "INITIATED");- final String script =- "@echo off" + serverCore.LF_STRING +- "title YaCy restarter" + serverCore.LF_STRING +- "set loading=YACY RESTARTER" + serverCore.LF_STRING +- "echo %loading%" + serverCore.LF_STRING +- "cd \"" + apphome + "/DATA/RELEASE/".replace("/", File.separator) + "\"" + serverCore.LF_STRING +- ":WAIT" + serverCore.LF_STRING +- "set loading=%loading%." + serverCore.LF_STRING +- "cls" + serverCore.LF_STRING +- "echo %loading%" + serverCore.LF_STRING +- "ping -n 2 127.0.0.1 >nul" + serverCore.LF_STRING +- "IF exist ..\\yacy.running goto WAIT" + serverCore.LF_STRING +- "cd \"" + apphome + "\"" + serverCore.LF_STRING +- "start /MIN CMD /C " + starterFile + serverCore.LF_STRING;- final File scriptFile = new File(sb.getRootPath(), "DATA/RELEASE/restart.bat".replace("/", File.separator));- serverSystem.deployScript(scriptFile, script);- Log.logInfo("RESTART", "wrote restart-script to " + scriptFile.getAbsolutePath());- serverSystem.execAsynchronous(scriptFile);- Log.logInfo("RESTART", "script is running");- sb.terminate(5000);- } catch (final IOException e) {- Log.logSevere("RESTART", "restart failed", e);- }-- // create yacy.restart file which is used in Windows startscript-/* final File yacyRestart = new File(sb.getRootPath(), "DATA/yacy.restart");- if (!yacyRestart.exists()) {- try {- yacyRestart.createNewFile();- plasmaSwitchboard.getSwitchboard().terminate(5000);- } catch (IOException e) {- serverLog.logSevere("SHUTDOWN", "restart failed", e);- }- }*/-- }+ public int compare(final yacyVersion v0, final yacyVersion v1) {+ return (Integer.valueOf(v0.getSvn())).compareTo(Integer.valueOf(v1.getSvn()));+ }- if (serverSystem.canExecUnix) {- // start a re-start daemon- try {- Log.logInfo("RESTART", "INITIATED");- final String script =- "#!/bin/sh" + serverCore.LF_STRING +- "cd " + sb.getRootPath() + "/DATA/RELEASE/" + serverCore.LF_STRING +- "while [ -f ../yacy.running ]; do" + serverCore.LF_STRING +- "sleep 1" + serverCore.LF_STRING +- "done" + serverCore.LF_STRING +- "cd ../../" + serverCore.LF_STRING +- "nohup ./startYACY.sh > /dev/null" + serverCore.LF_STRING;- final File scriptFile = new File(sb.getRootPath(), "DATA/RELEASE/restart.sh");- serverSystem.deployScript(scriptFile, script);- Log.logInfo("RESTART", "wrote restart-script to " + scriptFile.getAbsolutePath());- serverSystem.execAsynchronous(scriptFile);- Log.logInfo("RESTART", "script is running");- sb.terminate(5000);- } catch (final IOException e) {- Log.logSevere("RESTART", "restart failed", e);- }+ public boolean equals(final Object obj) {+ if(obj instanceof yacyVersion) {+ final yacyVersion v = (yacyVersion) obj;+ return (this.getSvn() == v.getSvn()) && (this.getName().equals(v.getName()));}+ return false;}-- /**- * stop yacy and run a batch script, applies a new release and restarts yacy- * @param releaseFile- */- public static void deployRelease(final File releaseFile) {- //byte[] script = ("cd " + plasmaSwitchboard.getSwitchboard().getRootPath() + ";while [ -e ../yacy.running ]; do sleep 1;done;tar xfz " + release + ";cp -Rf yacy/* ../../;rm -Rf yacy;cd ../../;startYACY.sh").getBytes();- try {- final plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();- final String apphome = sb.getRootPath().toString();- Log.logInfo("UPDATE", "INITIATED");- try{- tarTools.unTar(tarTools.getInputStream(releaseFile), sb.getRootPath() + "/DATA/RELEASE/".replace("/", File.separator));- } catch (final Exception e){- Log.logSevere("UNTAR", "failed", e);- }- String script = null;- String scriptFileName = null;- if(serverSystem.isWindows){- final File startType = new File(sb.getRootPath(), "DATA/yacy.noconsole".replace("/", File.separator));- String starterFile = "startYACY_debug.bat";- if (startType.exists()) starterFile = "startYACY.bat"; // startType noconsole- script =- "@echo off" + serverCore.LF_STRING +- "title YaCy updater" + serverCore.LF_STRING +- "set loading=YACY UPDATER" + serverCore.LF_STRING +- "echo %loading%" + serverCore.LF_STRING +- "cd \"" + apphome + "/DATA/RELEASE/".replace("/", File.separator) + "\"" + serverCore.LF_STRING +-- ":WAIT" + serverCore.LF_STRING +- "set loading=%loading%." + serverCore.LF_STRING +- "cls" + serverCore.LF_STRING +- "echo %loading%" + serverCore.LF_STRING +- "ping -n 2 127.0.0.1 >nul" + serverCore.LF_STRING +- "IF exist ..\\yacy.running goto WAIT" + serverCore.LF_STRING +- "IF not exist yacy goto NODATA" + serverCore.LF_STRING +- "cd yacy" + serverCore.LF_STRING +- "xcopy *.* \"" + apphome + "\" /E /Y >nul" + serverCore.LF_STRING +- // /E - all subdirectories- // /Y - don't ask- "cd .." + serverCore.LF_STRING +- "rd yacy /S /Q" + serverCore.LF_STRING +- // /S delete tree- // /Q don't ask- "goto END" + serverCore.LF_STRING +-- ":NODATA" + serverCore.LF_STRING +- "echo YACY UPDATER ERROR: NO UPDATE SOURCE FILES ON FILESYSTEM" + serverCore.LF_STRING +- "pause" + serverCore.LF_STRING +-- ":END" + serverCore.LF_STRING +- "cd \"" + apphome + "\"" + serverCore.LF_STRING +- "start /MIN CMD /C " + starterFile + serverCore.LF_STRING;- scriptFileName = "update.bat";- } else { // unix/linux- script =- "#!/bin/sh" + serverCore.LF_STRING +- "cd " + sb.getRootPath() + "/DATA/RELEASE/" + serverCore.LF_STRING +- /* ((releaseFile.getName().endsWith(".gz")) ?- // test gz-file for integrity and tar xfz then- ("if gunzip -t " + releaseFile.getAbsolutePath() + serverCore.LF_STRING +- "then" + serverCore.LF_STRING +- "gunzip -c " + releaseFile.getAbsolutePath() + " | tar xf -" + serverCore.LF_STRING) :- // just tar xf the file, no integrity test possible?- ("tar xf " + releaseFile.getAbsolutePath() + serverCore.LF_STRING)- ) +*/- "while [ -f ../yacy.running ]; do" + serverCore.LF_STRING +- "sleep 1" + serverCore.LF_STRING +- "done" + serverCore.LF_STRING +- "cp -Rf yacy/* " + apphome + serverCore.LF_STRING +- "rm -Rf yacy" + serverCore.LF_STRING +- /* ((releaseFile.getName().endsWith(".gz")) ?- // else-case of gunzip -t test: if failed, just restart- ("else" + serverCore.LF_STRING +- "while [ -f ../yacy.running ]; do" + serverCore.LF_STRING +- "sleep 1" + serverCore.LF_STRING +- "done" + serverCore.LF_STRING +- "fi" + serverCore.LF_STRING) :- // in case that we did not made the integrity test, there is no else case- ""- ) +*/- "cd " + apphome + serverCore.LF_STRING +- "nohup ./startYACY.sh > /dev/null" + serverCore.LF_STRING;- scriptFileName = "update.sh";- }- final File scriptFile = new File(sb.getRootPath(), "DATA/RELEASE/".replace("/", File.separator) + scriptFileName);- serverSystem.deployScript(scriptFile, script);- Log.logInfo("UPDATE", "wrote update-script to " + scriptFile.getAbsolutePath());- serverSystem.execAsynchronous(scriptFile);- Log.logInfo("UPDATE", "script is running");- sb.setConfig("update.time.deploy", System.currentTimeMillis());- sb.terminate(5000);- } catch (final IOException e) {- Log.logSevere("UPDATE", "update failed", e);- }+ public int hashCode() {+ return this.getName().hashCode();}-+/*** Converts combined version-string to a pretty string, e.g. "0.435/01818" or "dev/01818" (development version) or "dev/00000" (in case of wrong input)*@@ -637,12 +136,13 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya* If the major version is >= 0.11 - major version is replaced by "dev" and separated SVN-version by '/', e.g."dev/01818" <br>* "dev/00000" - If the input does not matcht the regular expression above*/- public static String combined2prettyVersion(final String ver) {+ public static String combined2prettyVersion(final String ver) {return combined2prettyVersion(ver, "");}- public static String combined2prettyVersion(final String ver, final String computerName) {- final Matcher matcher = Pattern.compile("\\A(\\d+\\.\\d{1,3})(\\d{0,5})\\z").matcher(ver);+ public static String combined2prettyVersion(final String ver, final String computerName) {+ final Matcher matcher = Pattern.compile("\\A(\\d+\\.\\d{1,3})(\\d{0,5})\\z").matcher(ver);+if (!matcher.find()) {Log.logWarning("STARTUP", "Peer '"+computerName+"': wrong format of version-string: '" + ver + "'. Using default string 'dev/00000' instead");return "dev/00000";@@ -653,8 +153,8 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<yafor(int i=revision.length();i<5;++i) revision += "0";return mainversion+"/"+revision;}-- /**++ /*** Combines the version of YaCy with the versionnumber from SVN to a* combined version*@@ -662,80 +162,45 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya* @param svn Current version given from SVN.* @return String with the combined version.*/- public static double versvn2combinedVersion(final double version, final int svn) {+ public static double versvn2combinedVersion(final double version, final int svn) {return (Math.rint((version*100000000.0) + (svn))/100000000);}-- public static void main(final String[] args) {- System.out.println(thisVersion());- final float base = (float) 0.53;- final String blacklist = "....[123]";- String test;- for (int i = 0; i < 20; i++) {- test = Float.toString(base + (((float) i) / 1000));- System.out.println(test + " is " + ((test.matches(blacklist)) ? "blacklisted" : " not blacklisted"));- }- }/**- * keep only releases of last month (minimum latest and 1 main (maybe the same))- *- * @param filesPath where all downloaded files reside- * @param deleteAfterDays+ * Timestamp of this version+ * @return timestamp*/- public static void deleteOldDownloads(final File filesPath, final int deleteAfterDays) {- // list downloaded releases- yacyVersion release;- final String[] downloaded = filesPath.list();-- // parse all filenames and put them in a sorted set- final SortedSet<yacyVersion> downloadedreleases = new TreeSet<yacyVersion>();- for (int j = 0; j < downloaded.length; j++) {- try {- release = new yacyVersion(downloaded[j]);- downloadedreleases.add(release);- } catch (final RuntimeException e) {- // not a valid release- }- }-- // if we have some files- if(downloadedreleases.size() > 0) {- Log.logFine("STARTUP", "deleting downloaded releases older than "+ deleteAfterDays +" days");-- // keep latest version- final yacyVersion latest = downloadedreleases.last();- downloadedreleases.remove(latest);- // if latest is a developer release, we also keep a main release- final boolean keepMain = !latest.mainRelease;-- // remove old files- final long now = System.currentTimeMillis();- final long deleteAfterMillis = deleteAfterDays * 24L * 60 * 60000;-- String lastMain = null;- String filename;- for (final yacyVersion aRelease : downloadedreleases) {- filename = aRelease.name;- if (keepMain && aRelease.mainRelease) {- // keep this one, delete last remembered main release file- if (lastMain != null) {- filename = lastMain;- }- lastMain = aRelease.name;- }+ public String getDateStamp() {+ return dateStamp;+ }- // check file age- final File downloadedFile = new File(filesPath + File.separator + filename);- if (now - downloadedFile.lastModified() > deleteAfterMillis) {- // delete file- FileUtils.deletedelete(downloadedFile);- if (downloadedFile.exists()) {- Log.logWarning("STARTUP", "cannot delete old release " + downloadedFile.getAbsolutePath());- }- }- }- }+ /**+ * SVN revision of release+ * @return svn revision as integer+ */+ public int getSvn() {+ return svn;+ }++ /**+ * Whether this is a stable main release or not+ * @return+ */+ public boolean isMainRelease() {+ return mainRelease;+ }++ /**+ * release number as float (e. g. 7.04)+ * @return+ */+ public float getReleaseNr() {+ return releaseNr;}--}+++ public String getName() {+ return name;+ }++}\ No newline at end of filediff --git a/source/yacy.java b/source/yacy.javaindex 92f44d22c..4aab6b845 100644--- a/source/yacy.java+++ b/source/yacy.java@@ -79,6 +79,7 @@ import de.anomic.yacy.yacyClient;import de.anomic.yacy.yacySeedDB;import de.anomic.yacy.Tray;import de.anomic.yacy.yacyURL;+import de.anomic.yacy.yacyRelease;import de.anomic.yacy.yacyVersion;/**@@ -251,7 +252,7 @@ public final class yacy {final String svrReleaseNr = matcher.group(1);try {try {version = Double.parseDouble(vString);} catch (final NumberFormatException e) {version = (float) 0.1;}- version = yacyVersion.versvn2combinedVersion(version, Integer.parseInt(svrReleaseNr));+ version = yacyRelease.versvn2combinedVersion(version, Integer.parseInt(svrReleaseNr));} catch (final NumberFormatException e) {}sb.setConfig("svnRevision", svrReleaseNr);}@@ -312,7 +313,7 @@ public final class yacy {// delete old release filesfinal int deleteOldDownloadsAfterDays = (int) sb.getConfigLong("update.deleteOld", 30);- yacyVersion.deleteOldDownloads(sb.releasePath, deleteOldDownloadsAfterDays );+ yacyRelease.deleteOldDownloads(sb.releasePath, deleteOldDownloadsAfterDays );// set user-agentfinal String userAgent = "yacy/" + Double.toString(version) + " (www.yacy.net; "