BUG 2042088 : SDK Updater: we want to keep getenv(TEMP_SDK_URL)
Renamed the getenv and added one for user sources. Added a (naive) check to prevent duplicate URLs. Also fixed the repositoy.xml download error message, it was not displaying the reason of failure correctly.
This commit is contained in:
@@ -56,6 +56,9 @@ public class RepoSource implements IDescription {
|
||||
|
||||
/**
|
||||
* Constructs a new source for the given repository URL.
|
||||
* @param url The source URL. Cannot be null. If the URL ends with a /, the default
|
||||
* repository.xml filename will be appended automatically.
|
||||
* @param userSource True if this a user source (add-ons & packages only.)
|
||||
*/
|
||||
public RepoSource(String url, boolean userSource) {
|
||||
|
||||
@@ -72,6 +75,23 @@ public class RepoSource implements IDescription {
|
||||
setDefaultDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
* Two repo source are equal if they have the same userSource flag and the same URL.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof RepoSource) {
|
||||
RepoSource rs = (RepoSource) obj;
|
||||
return rs.isUserSource() == this.isUserSource() && rs.getUrl().equals(this.getUrl());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mUrl.hashCode() ^ Boolean.valueOf(mUserSource).hashCode();
|
||||
}
|
||||
|
||||
/** Returns true if this is a user source. We only load addon and extra packages
|
||||
* from a user source and ignore the rest. */
|
||||
public boolean isUserSource() {
|
||||
@@ -176,7 +196,7 @@ public class RepoSource implements IDescription {
|
||||
}
|
||||
}
|
||||
|
||||
monitor.setResult("Failed to fetch URL %1$s, reason:", url, reason);
|
||||
monitor.setResult("Failed to fetch URL %1$s, reason: %2$s", url, reason);
|
||||
}
|
||||
|
||||
monitor.incProgress(1);
|
||||
|
||||
@@ -95,7 +95,10 @@ public class RepoSources {
|
||||
for (int i = 0; i < count; i++) {
|
||||
String url = props.getProperty(String.format("%s%02d", KEY_SRC, i)); //$NON-NLS-1$
|
||||
if (url != null) {
|
||||
mSources.add(new RepoSource(url, true /*userSource*/));
|
||||
RepoSource s = new RepoSource(url, true /*userSource*/);
|
||||
if (!hasSource(s)) {
|
||||
mSources.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,6 +122,20 @@ public class RepoSources {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if there's already a similar source in the sources list.
|
||||
* <p/>
|
||||
* The search is O(N), which should be acceptable on the expectedly small source list.
|
||||
*/
|
||||
public boolean hasSource(RepoSource source) {
|
||||
for (RepoSource s : mSources) {
|
||||
if (s.equals(source)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves all the user sources.
|
||||
* @param log
|
||||
|
||||
Reference in New Issue
Block a user