diff options
author | Mat Booth | 2018-11-22 14:37:13 +0000 |
---|---|---|
committer | Mat Booth | 2018-11-23 14:05:14 +0000 |
commit | 92ddc71e243823e903a9b9f9ab4e29c602577b6e (patch) | |
tree | eee818b559b7cf1a73a6209af71e31d043cd4372 /bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java | |
parent | c6014f6645c44eb9bae918f87ba079437a3e827b (diff) | |
download | rt.equinox.p2-92ddc71e243823e903a9b9f9ab4e29c602577b6e.tar.gz rt.equinox.p2-92ddc71e243823e903a9b9f9ab4e29c602577b6e.tar.xz rt.equinox.p2-92ddc71e243823e903a9b9f9ab4e29c602577b6e.zip |
Bug 541444 - source.info contains old/duplicate bundles after platform upgradeY20181205-2200Y20181204-0315Y20181128-2200S4_10_0_RC2S4_10_0_RC1R4_10I20181206-0815I20181206-0320I20181206-0225I20181206-0030I20181205-1800I20181205-0600I20181204-1800I20181204-0600I20181203-1800I20181203-0600I20181202-1800I20181202-0600I20181201-1800I20181201-0600I20181130-1800I20181129-0330I20181128-1800I20181128-1105I20181128-0810I20181128-0600I20181128-0130I20181127-1800I20181127-0600I20181126-1800I20181126-0940I20181126-0600I20181126-0140I20181125-1800I20181125-0600I20181124-1800I20181124-0600I20181123-1800R4_10_maintenance
This change takes advantage of the fact that simpleconfigurator
has already done the checking to see if the shared installation
has been updated and set a system property accordingly. We then
use the presence of the system property to determine whether to
ignore the user configuration or not.
Ignoring the user configuration means the source.info will be re
-generated from scratch using the bundles in the updated shared
configuration, then the migration wizard will re-insert any third
-party bundles as appropriate.
This avoids the possibility that there will be out-of-date
entries in the source.info in the user configuration area.
Change-Id: Ia59ce22133c928fe23b72c65a6034c5267f38f1b
Signed-off-by: Mat Booth <mat.booth@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java')
-rw-r--r-- | bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java index 5432b00bb..14a45c2c7 100644 --- a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java +++ b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java @@ -30,7 +30,6 @@ import org.eclipse.equinox.internal.simpleconfigurator.SimpleConfiguratorImpl; import org.eclipse.equinox.internal.simpleconfigurator.utils.EquinoxUtils; import org.eclipse.equinox.internal.simpleconfigurator.utils.SimpleConfiguratorUtils; import org.eclipse.equinox.simpleconfigurator.manipulator.SimpleConfiguratorManipulator; -import org.eclipse.osgi.service.datalocation.Location; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; @@ -204,8 +203,6 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani if (!state.isResolved()) state.resolve(false); - // if (DEBUG) - // System.out.println(state.toString()); if (!state.isResolved(bInfo)) { printoutUnsatisfiedConstraints(bInfo, state); @@ -301,12 +298,41 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani } } + /** + * Like {@link SimpleConfiguratorImpl#chooseConfigurationURL(URL, URL[])} but it doesn't check + * file timestamps because if the {@link SimpleConfiguratorImpl#PROP_IGNORE_USER_CONFIGURATION} + * property is set then we already know that timestamps have been checked and we need to ignore + * the user config. + */ + private URL chooseConfigurationURL(String relativePath, URL[] configURL) throws MalformedURLException { + if (configURL != null) { + File userConfig = new File(configURL[0].getFile(), relativePath); + if (configURL.length == 1) { + return userConfig.exists() ? userConfig.toURI().toURL() : null; + } + + File sharedConfig = new File(configURL[1].getFile(), relativePath); + if (!userConfig.exists()) { + return sharedConfig.exists() ? sharedConfig.toURI().toURL() : null; + } + + if (!sharedConfig.exists()) { + return userConfig.toURI().toURL(); + } + + if (Boolean.getBoolean(SimpleConfiguratorImpl.PROP_IGNORE_USER_CONFIGURATION)) { + return sharedConfig.toURI().toURL(); + } + return userConfig.toURI().toURL(); + } + return null; + } + @Override public BundleInfo[] loadConfiguration(BundleContext context, String infoPath) throws IOException { URI installArea = EquinoxUtils.getInstallLocationURI(context); URL configURL = null; - InputStream stream = null; if (infoPath == null) { SimpleConfiguratorImpl simpleImpl = new SimpleConfiguratorImpl(context, null); @@ -317,35 +343,23 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani if (defaultSource) infoPath = SOURCE_INFO_PATH; - Location configLocation = EquinoxUtils.getConfigLocation(context); - configURL = configLocation.getDataArea(infoPath); - try { - stream = configURL.openStream(); - } catch (FileNotFoundException e) { - if (defaultSource && configLocation.getParentLocation() != null) { - configURL = configLocation.getParentLocation().getDataArea(infoPath); - } else { - return new BundleInfo[0]; - } - } + URL[] configURLs = EquinoxUtils.getConfigAreaURL(context); + configURL = chooseConfigurationURL(infoPath, configURLs); } - if (configURL == null) - return new BundleInfo[0]; - else if (stream == null) { - try { - stream = configURL.openStream(); - } catch (FileNotFoundException e) { - return new BundleInfo[0]; - } + + // At this point the file specified by configURL should definitely exist or be null + if (configURL == null) { + return NULL_BUNDLEINFOS; } List<BundleInfo> result = new ArrayList<>(); - //stream will be closed - result.addAll(Arrays.asList(loadConfiguration(stream, installArea))); + // Stream will be closed by loadConfiguration + result.addAll(Arrays.asList(loadConfiguration(configURL.openStream(), installArea))); try { List<File> infoFiles = SimpleConfiguratorUtils.getInfoFiles(); for (File infoFile : infoFiles) { + // Stream will be closed by loadConfiguration BundleInfo[] info = loadConfiguration(infoFile.toURL().openStream(), infoFile.getParentFile().toURI()); result.addAll(Arrays.asList(info)); } @@ -353,7 +367,7 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani // ignore the extended configurations } - return result.toArray(new BundleInfo[0]); + return result.toArray(new BundleInfo[result.size()]); } /* |