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.
|
* 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) {
|
public RepoSource(String url, boolean userSource) {
|
||||||
|
|
||||||
@@ -72,6 +75,23 @@ public class RepoSource implements IDescription {
|
|||||||
setDefaultDescription();
|
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
|
/** Returns true if this is a user source. We only load addon and extra packages
|
||||||
* from a user source and ignore the rest. */
|
* from a user source and ignore the rest. */
|
||||||
public boolean isUserSource() {
|
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);
|
monitor.incProgress(1);
|
||||||
|
|||||||
@@ -95,7 +95,10 @@ public class RepoSources {
|
|||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
String url = props.getProperty(String.format("%s%02d", KEY_SRC, i)); //$NON-NLS-1$
|
String url = props.getProperty(String.format("%s%02d", KEY_SRC, i)); //$NON-NLS-1$
|
||||||
if (url != null) {
|
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.
|
* Saves all the user sources.
|
||||||
* @param log
|
* @param log
|
||||||
|
|||||||
@@ -335,17 +335,40 @@ public class UpdaterWindowImpl {
|
|||||||
RepoSources sources = mUpdaterData.getSources();
|
RepoSources sources = mUpdaterData.getSources();
|
||||||
sources.add(new RepoSource(SdkRepository.URL_GOOGLE_SDK_REPO_SITE, false /*userSource*/));
|
sources.add(new RepoSource(SdkRepository.URL_GOOGLE_SDK_REPO_SITE, false /*userSource*/));
|
||||||
|
|
||||||
String str = System.getenv("TEMP_SDK_URL"); // TODO STOPSHIP temporary remove before shipping
|
// SDK_UPDATER_URLS is a semicolon-separated list of URLs that can be used to
|
||||||
|
// seed the SDK Updater list for full repositories.
|
||||||
|
String str = System.getenv("SDK_UPDATER_URLS");
|
||||||
if (str != null) {
|
if (str != null) {
|
||||||
String[] urls = str.split(";");
|
String[] urls = str.split(";");
|
||||||
for (String url : urls) {
|
for (String url : urls) {
|
||||||
sources.add(new RepoSource(url, false /*userSource*/));
|
if (url != null && url.length() > 0) {
|
||||||
|
RepoSource s = new RepoSource(url, false /*userSource*/);
|
||||||
|
if (!sources.hasSource(s)) {
|
||||||
|
sources.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load user sources
|
// Load user sources
|
||||||
sources.loadUserSources(mUpdaterData.getSdkLog());
|
sources.loadUserSources(mUpdaterData.getSdkLog());
|
||||||
|
|
||||||
|
// SDK_UPDATER_USER_URLS is a semicolon-separated list of URLs that can be used to
|
||||||
|
// seed the SDK Updater list for user-only repositories. User sources can only provide
|
||||||
|
// add-ons and extra packages.
|
||||||
|
str = System.getenv("SDK_UPDATER_USER_URLS");
|
||||||
|
if (str != null) {
|
||||||
|
String[] urls = str.split(";");
|
||||||
|
for (String url : urls) {
|
||||||
|
if (url != null && url.length() > 0) {
|
||||||
|
RepoSource s = new RepoSource(url, true /*userSource*/);
|
||||||
|
if (!sources.hasSource(s)) {
|
||||||
|
sources.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mRemotePackagesPage.onSdkChange();
|
mRemotePackagesPage.onSdkChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user