[ 
https://issues.apache.org/jira/browse/CB-10314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15170377#comment-15170377
 ] 

ASF GitHub Bot commented on CB-10314:
-------------------------------------

Github user bso-intel commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/396#discussion_r54328731
  
    --- Diff: cordova-lib/src/plugman/install.js ---
    @@ -79,21 +79,36 @@ module.exports = function installPlugin(platform, 
project_dir, id, plugins_dir,
         }
     
         var current_stack = new action_stack();
    -
         // Split @Version from the plugin id if it exists.
         var splitVersion = id.split('@');
         //Check if a mapping exists for the plugin id
         //if it does, convert id to new name id
    -    var newId = pluginMapper[splitVersion[0]];
    +    var newId = pluginMapper.oldToNew[splitVersion[0]];
         if(newId) {
    -        events.emit('warn', 'Notice: ' + id + ' has been automatically 
converted to ' + newId + ' and fetched from npm. This is due to our old plugins 
registry shutting down.');
             if(splitVersion[1]) {
                 id = newId +'@'+splitVersion[1];
             } else {
                 id = newId;
             }
    -     }
    -    return possiblyFetch(id, plugins_dir, options)
    +    }
    +    var P;
    +    var plugin_dir = path.join(plugins_dir, splitVersion[0]);
    +    // if the plugin has already been fetched, use it.
    +    if (fs.existsSync(plugin_dir)) {
    +        P = Q(plugin_dir);
    +    } else {
    +        var alias = pluginMapper.newToOld[splitVersion[0]] || newId;
    +        // if the plugin alias has already been fetched, use it.
    +        if (alias && fs.existsSync(path.join(plugins_dir, alias))) {
    +            P = Q(path.join(plugins_dir, alias));
    --- End diff --
    
    I actually added a warning message in the fetch.js file.



> avoid fetching newId when oldId is already fetched
> --------------------------------------------------
>
>                 Key: CB-10314
>                 URL: https://issues.apache.org/jira/browse/CB-10314
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaLib
>            Reporter: Byoungro So
>            Assignee: Byoungro So
>            Priority: Minor
>              Labels: triaged
>
> As of Cordova 5.4.0, an old plugin id is automatically converted to a new id 
> using the corodva-registry-mapper.
> This causes a new id to be fetched even if an old id is already fetched in 
> the plugins directory (at cordova-lib/src/plugman/install.js)
> However, plugman/fetch.js/copyPlugin() checks if the alias id is already in 
> the plugins directory, and skips installing the fetched newId plugin.
> This causes unnecessary overhead.
> It is better to check if the oldId is already fetched, and skips fetching the 
> newId from the beginning.
> {code}
> [t6.0.1] cordova plugins
> cordova-plugin-whitelist 1.2.1 "Whitelist"
> org.apache.cordova.device 0.3.0 "Device"
> [t6.0.1] cordova plugin add org.apache.cordova.device
> Notice: org.apache.cordova.device has been automatically converted to 
> cordova-plugin-device to be fetched from npm. This is due to our old plugins 
> registry shutting down.
> Fetching plugin "cordova-plugin-device" via npm
> cordova-plugin-device" will not install due to 
> "/Users/bso/cordova/test/t6.0.1/plugins/org.apache.cordova.device" being 
> installed.
> Notice: org.apache.cordova.device has been automatically converted to 
> cordova-plugin-device and fetched from npm. This is due to our old plugins 
> registry shutting down.
> Fetching plugin "cordova-plugin-device" via npm
> cordova-plugin-device" will not install due to 
> "/Users/bso/cordova/test/t6.0.1/plugins/org.apache.cordova.device" being 
> installed.
> Plugin "org.apache.cordova.device" already installed on ios.
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to