gnodet-bot commented on code in PR #2184:
URL: https://github.com/apache/maven-resolver/pull/2184#discussion_r4208806339


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManager.java:
##########
@@ -236,22 +235,30 @@ public LocalArtifactResult find(RepositorySystemSession 
session, LocalArtifactRe
         return result;
     }
 
+    private Path getPrefixDirectory(String prefix) {
+        Path basePath = getRepository().getBasePath();
+        return prefix == null || prefix.isEmpty() ? basePath : 
basePath.resolve(prefix);
+    }
+
     /**
      * Verifies that the real (on-disk) spelling of the given artifact path 
matches the requested spelling,
-     * relative to the local repository base directory. On case-insensitive or 
normalization-preserving
+     * relative to the directory of its local path prefix. On case-insensitive 
or normalization-preserving
      * filesystems (the macOS and Windows defaults) a cached file whose stored 
name differs from the requested one
      * - for example one cached for case-colliding coordinates - still passes 
the file-existence check, while the
      * tracking data in the tracking file is compared exactly: the aliased 
file would then be treated as
      * present-but-untracked and accepted with no download and no checksum 
verification. Such aliases are treated
-     * as "not present" instead (fail closed), forcing a proper download for 
the requested coordinates. The
-     * comparison is relative to the (symlink-resolved) base directory, so a 
symlinked base directory is
-     * supported; symbolic links below the base directory are not - see
-     * {@link 
EnhancedLocalRepositoryManagerFactory#CONFIG_PROP_VERIFY_REAL_PATH} to opt out.
+     * as "not present" instead (fail closed), forcing a proper download for 
the requested coordinates. Only the
+     * coordinate-derived part of the path is compared: the base directory and 
the prefix directories are
+     * configuration, not coordinates, so they may be symbolic links; symbolic 
links below them are not supported -
+     * see {@link 
EnhancedLocalRepositoryManagerFactory#CONFIG_PROP_VERIFY_REAL_PATH} to opt out.
      */
-    private boolean hasFaithfulRealPath(Path path) {
+    private boolean hasFaithfulRealPath(Path prefixDirectory, Path path) {
         try {
-            String requested = 
getRepository().getBasePath().relativize(path).toString();
-            String real = 
realBasePath.relativize(path.toRealPath()).toString();
+            String requested = prefixDirectory
+                    .toRealPath()
+                    .resolve(prefixDirectory.relativize(path))

Review Comment:
   💡 `prefixDirectory.toRealPath()` is invoked on every call to 
`hasFaithfulRealPath`, i.e. on every artifact cache hit. The old code computed 
this once at construction time (`this.realBasePath = 
getRepository().getBasePath().toRealPath()`). With only 2–3 distinct prefix 
directories per session, these real paths could be memoised in a 
`ConcurrentHashMap<Path, Path>` (consistent with the existing 
`trackingFileCache` pattern) to avoid repeated syscalls on warm repository 
builds.



-- 
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