Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2011-01-27 14:24:38 -0500
committerDJ Houghton2011-01-27 14:24:38 -0500
commite3f7c0f1bf575ca8e38773ce2485f63eecb1c36e (patch)
tree01f73de119bde647babfc1462cb225435a06d744 /bundles
parentcaa2cabaf375fc33ba7235fa0c9c3a6aaf6ad289 (diff)
downloadrt.equinox.p2-e3f7c0f1bf575ca8e38773ce2485f63eecb1c36e.tar.gz
rt.equinox.p2-e3f7c0f1bf575ca8e38773ce2485f63eecb1c36e.tar.xz
rt.equinox.p2-e3f7c0f1bf575ca8e38773ce2485f63eecb1c36e.zip
Bug 335153 - Regression: p2 downloads are much slower due to picking remote artifacts even when a local file: URL is available
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java
index 833aad80d..8daa26bae 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,8 +11,7 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.engine;
-import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.engine.phases.Collect;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
@@ -27,6 +26,25 @@ public class DownloadManager {
ArrayList<IArtifactRequest> requestsToProcess = new ArrayList<IArtifactRequest>();
private IProvisioningAgent agent = null;
+ /**
+ * This Comparator sorts the repositories such that local repositories are first.
+ * TODO: This is copied from the ProvisioningContext class. Can we combine them?
+ * See https://bugs.eclipse.org/335153.
+ */
+ private static final Comparator<IArtifactRepository> LOCAL_FIRST_COMPARATOR = new Comparator<IArtifactRepository>() {
+ private static final String FILE_PROTOCOL = "file"; //$NON-NLS-1$
+
+ public int compare(IArtifactRepository arg0, IArtifactRepository arg1) {
+ String protocol0 = arg0.getLocation().getScheme();
+ String protocol1 = arg1.getLocation().getScheme();
+ if (FILE_PROTOCOL.equals(protocol0) && !FILE_PROTOCOL.equals(protocol1))
+ return -1;
+ if (!FILE_PROTOCOL.equals(protocol0) && FILE_PROTOCOL.equals(protocol1))
+ return 1;
+ return 0;
+ }
+ };
+
public DownloadManager(ProvisioningContext context, IProvisioningAgent agent) {
provContext = context;
this.agent = agent;
@@ -74,6 +92,10 @@ public class DownloadManager {
IArtifactRepository[] repositories = repoQueryable.query(all, subMonitor.newChild(250)).toArray(IArtifactRepository.class);
if (repositories.length == 0)
return new Status(IStatus.ERROR, EngineActivator.ID, Messages.download_no_repository, new Exception(Collect.NO_ARTIFACT_REPOSITORIES_AVAILABLE));
+ // Although we get a sorted list back from the ProvisioningContext above, it
+ // gets unsorted when we convert the queryable into an array so we must re-sort it.
+ // See https://bugs.eclipse.org/335153.
+ Arrays.sort(repositories, LOCAL_FIRST_COMPARATOR);
fetch(repositories, subMonitor.newChild(500));
return overallStatus(monitor);
} finally {

Back to the top