You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/05/17 21:11:08 UTC

[maven-build-cache-extension] 01/02: [MBUILDCACHE-21] Exclude files and directories which are not readable

This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-build-cache-extension.git

commit 71994712bc50f0880594d24ece2b7f46d6d96196
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue May 17 09:50:40 2022 +0200

    [MBUILDCACHE-21] Exclude files and directories which are not readable
---
 .../apache/maven/buildcache/checksum/MavenProjectInput.java  | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/maven/buildcache/checksum/MavenProjectInput.java b/src/main/java/org/apache/maven/buildcache/checksum/MavenProjectInput.java
index a717421..0c99a78 100644
--- a/src/main/java/org/apache/maven/buildcache/checksum/MavenProjectInput.java
+++ b/src/main/java/org/apache/maven/buildcache/checksum/MavenProjectInput.java
@@ -526,6 +526,11 @@ public class MavenProjectInput
                     LOGGER.debug( "Skipping subtree (hidden): {}", path );
                     return FileVisitResult.SKIP_SUBTREE;
                 }
+                else if ( !isReadable( path ) )
+                {
+                    LOGGER.debug( "Skipping subtree (not readable): {}", path );
+                    return FileVisitResult.SKIP_SUBTREE;
+                }
                 else if ( isFilteredOutSubpath( path ) )
                 {
                     LOGGER.debug( "Skipping subtree (blacklisted): {}", path );
@@ -648,7 +653,7 @@ public class MavenProjectInput
                         continue;
                     }
                     File file = entry.toFile();
-                    if ( file.isFile() && !isHidden( entry ) )
+                    if ( file.isFile() && !isHidden( entry ) && isReadable( entry ) )
                     {
                         collectedFiles.add( entry );
                     }
@@ -666,6 +671,11 @@ public class MavenProjectInput
         return Files.isHidden( entry ) || entry.toFile().getName().startsWith( "." );
     }
 
+    private static boolean isReadable( Path entry ) throws IOException
+    {
+        return Files.isReadable( entry );
+    }
+
     private boolean isFilteredOutSubpath( Path path )
     {
         Path normalized = path.normalize();