FELIX-1736: after a restart, fileinstall does not always properly uninstall bundles

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@824250 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 c2e751e..3d8dd83 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
@@ -699,6 +699,10 @@
         try
         {
             File path = artifact.getPath();
+            // Find a listener for this artifact if needed
+            if (artifact.getListener() == null) {
+                artifact.setListener(findListener(path, FileInstall.getListeners()));
+            }
             // Forget this artifact
             currentManagedArtifacts.remove(path);
             // Delete transformed file
@@ -709,7 +713,7 @@
                 ((ArtifactInstaller) artifact.getListener()).uninstall(path);
             }
             // else we need uninstall the bundle
-            else if (artifact.getListener() instanceof ArtifactTransformer)
+            else if (artifact.getBundleId() != 0)
             {
                 // old can't be null because of the way we calculate deleted list.
                 bundle = context.getBundle(artifact.getBundleId());
@@ -721,6 +725,7 @@
                         + ". The bundle has already been uninstalled", null);
                     return null;
                 }
+                log("Uninstalling bundle " + bundle.getBundleId() + " (" + bundle.getSymbolicName() + ")", null);
                 bundle.uninstall();
             }
             log("Uninstalled " + path, null);