summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2013-01-18 16:16:18 (EST)
committerPascal Rapicault2013-01-18 16:16:18 (EST)
commit6067d05e402fe796debd9d25604cae7026df5b48 (patch)
treeeb425da4f8082b2dbb3c9ef47594aac00fcc3be8
parent8ab9410d8c797e6a8d2a97e4ba46da3d548440fa (diff)
downloadrt.equinox.p2-6067d05e402fe796debd9d25604cae7026df5b48.zip
rt.equinox.p2-6067d05e402fe796debd9d25604cae7026df5b48.tar.gz
rt.equinox.p2-6067d05e402fe796debd9d25604cae7026df5b48.tar.bz2
only write timestamp file for shared install
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java59
1 files changed, 51 insertions, 8 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 6fe8fa6..219dfb1 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
@@ -396,7 +396,7 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
return;
}
SimpleConfiguratorManipulatorUtils.writeConfiguration(simpleInfos, outputFile);
- if (CONFIG_LIST.equals(outputFile.getName()))
+ if (CONFIG_LIST.equals(outputFile.getName()) && isSharedInstallSetup(URIUtil.toFile(installArea), outputFile))
rememberSharedBundlesInfoTimestamp(installArea, outputFile.getParentFile());
}
@@ -522,13 +522,17 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
File configFile = getConfigFile(manipulator);
File installArea = ParserUtils.getOSGiInstallArea(Arrays.asList(manipulator.getLauncherData().getProgramArgs()), manipulator.getConfigData().getProperties(), manipulator.getLauncherData());
- BundleInfo[] toInstall = null;
- try {
- //input stream will be closed for us
- toInstall = loadConfiguration(new FileInputStream(configFile), installArea.toURI());
- } catch (FileNotFoundException e) {
- //no file, just return an empty list
- toInstall = new BundleInfo[0];
+ BundleInfo[] toInstall = new BundleInfo[0];
+
+ boolean isShared = isSharedInstallSetup(installArea, configFile);
+ if (!isShared || (isShared && !hasBaseChanged(installArea.toURI(), configFile.getParentFile()))) {
+ try {
+ //input stream will be closed for us
+ toInstall = loadConfiguration(new FileInputStream(configFile), installArea.toURI());
+ } catch (FileNotFoundException e) {
+ //no file, just return an empty list
+ toInstall = new BundleInfo[0];
+ }
}
List toUninstall = new LinkedList();
@@ -568,4 +572,43 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
if (outputFile.getParentFile().isDirectory())
outputFile.getParentFile().delete();
}
+
+ private boolean hasBaseChanged(URI installArea, File outputFolder) {
+ String rememberedTimestamp;
+ try {
+ rememberedTimestamp = (String) loadProperties(new File(outputFolder, SimpleConfiguratorImpl.BASE_TIMESTAMP_FILE_BUNDLESINFO)).get(SimpleConfiguratorImpl.KEY_BUNDLESINFO_TIMESTAMP);
+ } catch (IOException e) {
+ return false;
+ }
+ if (rememberedTimestamp == null)
+ return false;
+
+ File sharedBundlesInfo = new File(URIUtil.append(installArea, "configuration" + File.separatorChar + CONFIGURATOR_FOLDER + File.separatorChar + CONFIG_LIST));
+ if (!sharedBundlesInfo.exists())
+ return true;
+ return !String.valueOf(sharedBundlesInfo.lastModified()).equals(rememberedTimestamp);
+ }
+
+ private boolean isSharedInstallSetup(File installArea, File outputFile) {
+ //An instance is treated as shared if the bundles.info file is not located in the install area.
+ return !new File(installArea, "configuration" + File.separatorChar + CONFIGURATOR_FOLDER + File.separatorChar + CONFIG_LIST).equals(outputFile);
+ }
+
+ private Properties loadProperties(File inputFile) throws FileNotFoundException, IOException {
+ Properties props = new Properties();
+ InputStream is = null;
+ try {
+ is = new FileInputStream(inputFile);
+ props.load(is);
+ } finally {
+ try {
+ if (is != null)
+ is.close();
+ } catch (IOException e) {
+ //Do nothing
+ }
+ is = null;
+ }
+ return props;
+ }
}