[FELIX-4436] [fileinstall] Do not refresh bundles that have not been modified
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1585732 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
index c6a8f3d..4013dc0 100644
--- a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
+++ b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
@@ -922,6 +922,7 @@
{
File path = artifact.getPath();
Bundle bundle = null;
+ AtomicBoolean modified = new AtomicBoolean();
try
{
// If the listener is an installer, ask for an update
@@ -942,7 +943,7 @@
BufferedInputStream in = new BufferedInputStream(transformed.openStream());
try
{
- bundle = installOrUpdateBundle(location, in, artifact.getChecksum());
+ bundle = installOrUpdateBundle(location, in, artifact.getChecksum(), modified);
}
finally
{
@@ -963,7 +964,7 @@
BufferedInputStream in = new BufferedInputStream(new FileInputStream(transformed != null ? transformed : path));
try
{
- bundle = installOrUpdateBundle(location, in, artifact.getChecksum());
+ bundle = installOrUpdateBundle(location, in, artifact.getChecksum(), modified);
}
finally
{
@@ -983,11 +984,11 @@
// jar has been modified.
installationFailures.put(path, artifact);
}
- return bundle;
+ return modified.get() ? bundle : null;
}
private Bundle installOrUpdateBundle(
- String bundleLocation, BufferedInputStream is, long checksum)
+ String bundleLocation, BufferedInputStream is, long checksum, AtomicBoolean modified)
throws IOException, BundleException
{
is.mark(256 * 1024);
@@ -1017,6 +1018,7 @@
stopTransient(b);
Util.storeChecksum(b, checksum, context);
b.update(is);
+ modified.set(true);
}
return b;
}
@@ -1027,7 +1029,8 @@
+ " / " + v, null);
Bundle b = context.installBundle(bundleLocation, is);
Util.storeChecksum(b, checksum, context);
-
+ modified.set(true);
+
// Set default start level at install time, the user can override it if he wants
if (startLevel != 0)
{