nickva commented on code in PR #6197:
URL: https://github.com/apache/couchdb/pull/6197#discussion_r4458789376


##########
extra/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java:
##########
@@ -280,35 +280,56 @@ public void deleteAll(final String path, final 
List<String> exclusions) throws I
 
             @Override
             public FileVisitResult preVisitDirectory(Path dir, 
BasicFileAttributes attrs) throws IOException {
+                var relative = rootDir.relativize(dir);
+                if (dir.equals(rootDir)) {
+                    return FileVisitResult.CONTINUE;
+                }
                 // Skip subtree on first path component mismatch
-                for (int i = 0; i < dir.getNameCount(); i++) {
-                    if (!pathMatchers.get(i).matches(dir.subpath(i, i + 1))) {
+                for (int i = 0; i < relative.getNameCount(); i++) {
+                    if (!pathMatchers.get(i).matches(relative.subpath(i, i + 
1))) {
                         return FileVisitResult.SKIP_SUBTREE;
                     }
                 }
                 // We're not at full depth yet
-                if (dir.getNameCount() < pathMatchers.size()) {
+                if (relative.getNameCount() < pathMatchers.size()) {
                     return FileVisitResult.CONTINUE;
                 }
                 // Skip exclusions
-                if (exclusions != null && 
exclusions.contains(dir.getFileName().toString())) {
+                if (exclusions != null
+                        && 
exclusions.contains(relative.getFileName().toString())) {
+                    return FileVisitResult.SKIP_SUBTREE;
+                }
+                // Skip non-indexes
+                if (!isIndex(dir)) {
                     return FileVisitResult.SKIP_SUBTREE;
                 }
                 // Delete this index
                 try {
-                    unload(rootDir.relativize(dir), true);
+                    unload(relative, true);
                 } catch (InterruptedException e) {
-                    LOGGER.info("Interrupted during deleteAll", e);
-                    return FileVisitResult.TERMINATE;
+                    Thread.currentThread().interrupt();

Review Comment:
   This is an interesting pattern. I had to look it up and found the reason for 
it in 
https://stackoverflow.com/questions/4906799/why-invoke-thread-currentthread-interrupt-in-a-catch-interruptexception-block



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to