Set needsScan to false at the end of a scan instead of at the beginning in order to keep scanning when an exception occurs during a scan (SLING-6786).

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1792627 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/installer/provider/jcr/impl/WatchedFolder.java b/src/main/java/org/apache/sling/installer/provider/jcr/impl/WatchedFolder.java
index 1c67427..6f32ebf 100644
--- a/src/main/java/org/apache/sling/installer/provider/jcr/impl/WatchedFolder.java
+++ b/src/main/java/org/apache/sling/installer/provider/jcr/impl/WatchedFolder.java
@@ -115,7 +115,6 @@
      */
     public ScanResult scan() throws RepositoryException {
         logger.debug("Scanning {}", path);
-        needsScan = false;
 
         Node folder = null;
         if (session.itemExists(path)) {
@@ -150,6 +149,8 @@
             digests.put(r.getId(), r.getDigest());
         }
 
+        needsScan = false;
+
         return result;
     }