forked from I2P_Developers/i2p.i2p
* Updater: Fix plugin update checker (ticket #897)
* Utils: Reduce logging in wrapper log when extracting zip files
This commit is contained in:
@ -30,14 +30,12 @@ import net.i2p.util.VersionComparator;
|
||||
* @since 0.7.12
|
||||
*/
|
||||
class PluginUpdateChecker extends UpdateRunner {
|
||||
private final ByteArrayOutputStream _baos;
|
||||
private final String _appName;
|
||||
private final String _oldVersion;
|
||||
|
||||
public PluginUpdateChecker(RouterContext ctx, ConsoleUpdateManager mgr,
|
||||
List<URI> uris, String appName, String oldVersion ) {
|
||||
super(ctx, mgr, uris);
|
||||
_baos = new ByteArrayOutputStream(TrustedUpdate.HEADER_BYTES);
|
||||
super(ctx, mgr, uris, oldVersion);
|
||||
if (!uris.isEmpty())
|
||||
_currentURI = uris.get(0);
|
||||
_appName = appName;
|
||||
@ -85,7 +83,10 @@ class PluginUpdateChecker extends UpdateRunner {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining,
|
||||
String url, String outputFile, boolean notModified) {
|
||||
super.transferComplete(alreadyTransferred, bytesTransferred, bytesRemaining,
|
||||
url, outputFile, notModified);
|
||||
// super sets _newVersion if newer
|
||||
boolean newer = _newVersion != null;
|
||||
if (newer) {
|
||||
|
@ -21,6 +21,7 @@ import net.i2p.update.*;
|
||||
import net.i2p.util.EepGet;
|
||||
import net.i2p.util.FileUtil;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.OrderedProperties;
|
||||
import net.i2p.util.SecureDirectory;
|
||||
import net.i2p.util.SecureFile;
|
||||
@ -147,7 +148,7 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
return;
|
||||
}
|
||||
File tempDir = new File(_context.getTempDir(), "tmp" + _context.random().nextInt() + "-unzip");
|
||||
if (!FileUtil.extractZip(to, tempDir)) {
|
||||
if (!FileUtil.extractZip(to, tempDir, Log.ERROR)) {
|
||||
f.delete();
|
||||
to.delete();
|
||||
FileUtil.rmdir(tempDir, false);
|
||||
@ -374,7 +375,7 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
}
|
||||
|
||||
// Finally, extract the zip to the plugin directory
|
||||
if (!FileUtil.extractZip(to, destDir)) {
|
||||
if (!FileUtil.extractZip(to, destDir, Log.WARN)) {
|
||||
to.delete();
|
||||
statusDone("<b>" + _("Failed to install plugin in {0}", destDir.getAbsolutePath()) + "</b>");
|
||||
return;
|
||||
|
@ -39,9 +39,10 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
||||
protected boolean _isPartial;
|
||||
/** set by the listeners on completion */
|
||||
protected String _newVersion;
|
||||
// 56 byte header, only used for suds
|
||||
private final ByteArrayOutputStream _baos;
|
||||
/** 56 byte header, only used for suds */
|
||||
protected final ByteArrayOutputStream _baos;
|
||||
protected URI _currentURI;
|
||||
private final String _currentVersion;
|
||||
|
||||
private static final String SIGNED_UPDATE_FILE = "i2pupdate.sud";
|
||||
|
||||
@ -49,7 +50,18 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
||||
protected static final long INACTIVITY_TIMEOUT = 5*60*1000;
|
||||
protected static final long NOPROXY_INACTIVITY_TIMEOUT = 60*1000;
|
||||
|
||||
/**
|
||||
* Uses router version for partial checks
|
||||
*/
|
||||
public UpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, List<URI> uris) {
|
||||
this(ctx, mgr, uris, RouterVersion.VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param currentVersion used for partial checks
|
||||
* @since 0.9.7
|
||||
*/
|
||||
public UpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, List<URI> uris, String currentVersion) {
|
||||
super("Update Runner");
|
||||
setDaemon(true);
|
||||
_context = ctx;
|
||||
@ -58,6 +70,7 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
||||
_urls = uris;
|
||||
_baos = new ByteArrayOutputStream(TrustedUpdate.HEADER_BYTES);
|
||||
_updateFile = (new File(ctx.getTempDir(), "update" + ctx.random().nextInt() + ".tmp")).getAbsolutePath();
|
||||
_currentVersion = currentVersion;
|
||||
}
|
||||
|
||||
//////// begin UpdateTask methods
|
||||
@ -184,7 +197,7 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
||||
if (_isPartial) {
|
||||
// Compare version with what we have now
|
||||
String newVersion = TrustedUpdate.getVersionString(new ByteArrayInputStream(_baos.toByteArray()));
|
||||
boolean newer = VersionComparator.comp(newVersion, RouterVersion.VERSION) > 0;
|
||||
boolean newer = VersionComparator.comp(newVersion, _currentVersion) > 0;
|
||||
if (newer) {
|
||||
_newVersion = newVersion;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user