Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java36
1 files changed, 25 insertions, 11 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
index db511d26a..9736154cf 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
@@ -638,17 +638,9 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
//add the repository first so that it will be enabled, but don't send add event until after the load
added = addRepository(location, true, false);
- // get the search order from the server, if it's available
- ByteArrayOutputStream index = new ByteArrayOutputStream();
- LocationProperties locationProperties = null;
- try {
- getTransport().download(getIndexFile(location), index, monitor);
- } catch (Throwable e) {
- // If any exceptions are thrown, just ignore the index file
- }
+ LocationProperties indexFile = loadIndexFile(location, monitor);
- locationProperties = LocationProperties.create(new ByteArrayInputStream(index.toByteArray()));
- String[] preferredOrder = getPreferredRepositorySearchOrder(locationProperties);
+ String[] preferredOrder = getPreferredRepositorySearchOrder(indexFile);
String[] suffixes = sortSuffixes(getAllSuffixes(), location, preferredOrder);
SubMonitor sub = SubMonitor.convert(monitor, NLS.bind(Messages.repoMan_adding, location), suffixes.length * 100);
@@ -694,6 +686,28 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
}
/**
+ * Fetches the p2.index file from the server. If the file could not be fetched
+ * a NullSafe version is returned.
+ */
+ private LocationProperties loadIndexFile(URI location, IProgressMonitor monitor) {
+ // get the search order from the server, if it's available
+ ByteArrayOutputStream index = new ByteArrayOutputStream();
+ LocationProperties locationProperties = LocationProperties.createEmptyIndexFile();
+ IStatus indexFileStatus = null;
+ try {
+ indexFileStatus = getTransport().download(getIndexFileURI(location), index, monitor);
+ } catch (URISyntaxException uriSyntaxException) {
+ LogHelper.log(new Status(IStatus.ERROR, Activator.ID, uriSyntaxException.getMessage(), uriSyntaxException));
+ indexFileStatus = null;
+ }
+
+ if (indexFileStatus != null && indexFileStatus.isOK())
+ locationProperties = LocationProperties.create(new ByteArrayInputStream(index.toByteArray()));
+
+ return locationProperties;
+ }
+
+ /**
* Basic sanity checking on location argument
*/
private URI checkValidLocation(URI location) {
@@ -1121,7 +1135,7 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
}
}
- private static URI getIndexFile(URI base) throws URISyntaxException {
+ private static URI getIndexFileURI(URI base) throws URISyntaxException {
final String name = INDEX_FILE;
String spec = base.toString();
if (spec.endsWith(name))

Back to the top