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

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

raphinesse closed pull request #605: CB-13293 : if fetch has been called 
already, no need to fetch again
URL: https://github.com/apache/cordova-lib/pull/605
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/spec/cordova/platform/addHelper.spec.js 
b/spec/cordova/platform/addHelper.spec.js
index ce7607824..65caa3a72 100644
--- a/spec/cordova/platform/addHelper.spec.js
+++ b/spec/cordova/platform/addHelper.spec.js
@@ -355,6 +355,16 @@ describe('cordova/platform/addHelper', function () {
                     fail('fail handler unexpectedly invoked');
                 }).done(done);
             }, 60000);
+
+            it('should not fetch if platform has already been fetched', 
function (done) {
+                fs.existsSync.and.returnValue('android');
+                platform_addHelper.downloadPlatform(projectRoot, 'android', 
'6.0.0', {fetch: true}).then(function () {
+                    expect(fetch_mock).not.toHaveBeenCalled();
+                    expect(events.emit).not.toHaveBeenCalled();
+                }).fail(function (e) {
+                    fail('fail handler unexpectedly invoked');
+                }).done(done);
+            }, 60000);
         });
     });
     describe('installPluginsForNewPlatform', function () {
diff --git a/src/cordova/platform/addHelper.js 
b/src/cordova/platform/addHelper.js
index 87ff75282..02e326ae2 100644
--- a/src/cordova/platform/addHelper.js
+++ b/src/cordova/platform/addHelper.js
@@ -291,7 +291,9 @@ function getVersionFromConfigFile (platform, cfg) {
 function downloadPlatform (projectRoot, platform, version, opts) {
     var target = version ? (platform + '@' + version) : platform;
     return Q().then(function () {
-        if (opts.fetch) {
+        var platformPath = path.join(projectRoot, 'platforms', platform);
+        var platformAlreadyAdded = fs.existsSync(platformPath);
+        if ((opts.fetch) && (!platformAlreadyAdded)) {
             // append cordova to platform
             if (platform in platforms) {
                 target = 'cordova-' + target;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> already fetched platforms shouldn't call fetch code
> ---------------------------------------------------
>
>                 Key: CB-13293
>                 URL: https://issues.apache.org/jira/browse/CB-13293
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-lib
>            Reporter: Steve Gill
>            Assignee: Audrey So
>            Priority: Major
>              Labels: tools-next
>             Fix For: cordova@7.1.0
>
>
> adding a platform that has already been added/fetched will still call 
> cordova-fetch before realizing the platform is already installed. Need to 
> check if platform is added first. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to