Changeset 1f407bc


Ignore:
Timestamp:
Mar 15, 2012 12:39:11 AM (10 years ago)
Author:
sponge <sponge@…>
Branches:
master
Children:
d9ba62a
Parents:
1aa6367
Message:

Plugins

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java

    r1aa6367 r1f407bc  
    202202        if(pluginUpdate.exists()) {
    203203            // Compare the start time of the router with the plugin.
    204             List<RouterContext> contexts = RouterContext.listContexts();
    205             if ( (contexts == null) || (contexts.isEmpty()) )
    206                 throw new IllegalStateException("No contexts. This is usually because the router is either starting up or shutting down.");
    207             if(contexts.get(0).router().getWhenStarted() > pluginUpdate.lastModified()) {
     204            if(ctx.router().getWhenStarted() > pluginUpdate.lastModified()) {
    208205                if (!FileUtil.extractZip(pluginUpdate, pluginDir)) {
    209206                    pluginUpdate.delete();
  • apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateHandler.java

    r1aa6367 r1f407bc  
    122122        protected void update() {
    123123            _updated = false;
    124             updateStatus("<b>" + _("Downloading plugin from {0}", _xpi2pURL) + "</b>");
    125124            if(_xpi2pURL.startsWith("file://")) {
     125                updateStatus("<b>" + _("Attempting to copy plugin from {0}", _xpi2pURL) + "</b>");
    126126                // strip off "file://"
    127127                String xpi2pfile = _xpi2pURL.substring(7);
    128                 if(xpi2pfile.isEmpty()) {
     128                if(xpi2pfile.length() == 0) { // This is actually what String.isEmpty() does, so it should be safe.
    129129                        statusDone("<b>" + _("No file specified {0}", _xpi2pURL) + "</b>");
    130130                } else {
    131                     try {
    132                         // copy the contents of from to _updateFile
    133                         long alreadyTransferred = (new File(xpi2pfile)).getCanonicalFile().length();
    134                         if(FileUtil.copy((new File(xpi2pfile)).getCanonicalPath(), _updateFile, true, false)) {
    135                             transferComplete(alreadyTransferred, alreadyTransferred, 0L, _xpi2pURL, _updateFile, false);
    136                         } else {
    137                             statusDone("<b>" + _("File copy failed {0}", _xpi2pURL) + "</b>");
    138                         }
    139                     } catch (Throwable t) {
    140                         _log.error("Error copying plugin {0}", t);
     131                    // copy the contents of from to _updateFile
     132                    long alreadyTransferred = (new File(xpi2pfile)).getAbsoluteFile().length();
     133                    if(FileUtil.copy((new File(xpi2pfile)).getAbsolutePath(), _updateFile, true, false)) {
     134                        transferComplete(alreadyTransferred, alreadyTransferred, 0L, _xpi2pURL, _updateFile, false);
     135                    } else {
     136                        statusDone("<b>" + _("Failed to copy file {0}", _xpi2pURL) + "</b>");
    141137                    }
    142 
    143138                }
    144139            } else {
     140                updateStatus("<b>" + _("Downloading plugin from {0}", _xpi2pURL) + "</b>");
    145141                // use the same settings as for updater
    146142                boolean shouldProxy = Boolean.valueOf(_context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY)).booleanValue();
     
    178174        @Override
    179175        public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
     176            boolean update = false;
    180177            updateStatus("<b>" + _("Plugin downloaded") + "</b>");
    181178            File f = new File(_updateFile);
     
    407404                    }
    408405                }
    409 
     406                update = true;
    410407            } else {
    411408                if (Boolean.valueOf(props.getProperty("update-only")).booleanValue()) {
     
    429426            _updated = true;
    430427            to.delete();
    431             if (Boolean.valueOf(props.getProperty("dont-start-at-install")).booleanValue()) {
    432                 if (Boolean.valueOf(props.getProperty("router-restart-required")).booleanValue())
    433                     statusDone("<b>" + _("Plugin {0} installed, router restart required", appName) + "</b>");
    434                 else {
    435                     statusDone("<b>" + _("Plugin {0} installed", appName) + "</b>");
     428            // install != update. Changing the user's settings like this is probabbly a bad idea.
     429            if (Boolean.valueOf( props.getProperty("dont-start-at-install")).booleanValue()) {
     430                statusDone("<b>" + _("Plugin {0} installed", appName) + "</b>");
     431                if(!update) {
    436432                    Properties pluginProps = PluginStarter.pluginProperties();
    437433                    pluginProps.setProperty(PluginStarter.PREFIX + appName + PluginStarter.ENABLED, "false");
  • history.txt

    r1aa6367 r1f407bc  
     12012-03-15 sponge
     2  * Plugins:
     3    - String.isEmpty() [ java 6 ] -> (String.length() == 0) [ java 5 ]
     4    - for a file: URL, use "Attempting to copy plugin from" message
     5    - s/{0}// on non-translated string
     6    - grammar: "File copy failed {0}" -> "Failed to copy file from {0}"
     7    - use the context provided to get startup time
     8    - getCanonicalPath() -> getAbsolutePath()
     9    - install != update. Don't change the user's settings, and don't restart
     10      it on an update if "dont-start-at-install". This gives the same
     11      functionality as before.
     12
    1132012-03-14 zzz
    214  * Blockfile, i2psnark: Remove static logs
Note: See TracChangeset for help on using the changeset viewer.