erik-meuwese-topicus commented on code in PR #394:
URL: 
https://github.com/apache/maven-build-cache-extension/pull/394#discussion_r2567830667


##########
src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java:
##########
@@ -336,6 +353,41 @@ private UnaryOperator<File> 
createRestorationToDiskConsumer(final MavenProject p
         return file -> file;
     }
 
+    /**
+     * Restores an artifact from cache to disk, handling both regular files 
and directory artifacts.
+     * Directory artifacts (cached as zips) are unzipped back to their 
original directory structure.
+     */
+    private void restoreArtifactToDisk(File cachedFile, Artifact artifact, 
Path restorationPath) throws IOException {
+        // Check the explicit isDirectory flag set during save.
+        // Directory artifacts (e.g., target/classes) are saved as zips and 
need to be unzipped on restore.
+        if (artifact.isIsDirectory()) {
+            restoreDirectoryArtifact(cachedFile, artifact, restorationPath);
+        } else {
+            restoreRegularFileArtifact(cachedFile, artifact, restorationPath);
+        }
+    }
+
+    /**
+     * Restores a directory artifact by unzipping the cached zip file.
+     */
+    private void restoreDirectoryArtifact(File cachedZip, Artifact artifact, 
Path restorationPath) throws IOException {
+        if (!Files.exists(restorationPath)) {
+            Files.createDirectories(restorationPath);
+        }
+        CacheUtils.unzip(cachedZip.toPath(), restorationPath);

Review Comment:
   `CacheUtils.unzip(cachedZip.toPath(), restorationPath)` misses the last 
parameter `preservePermissions` whether to preserve Unix file permissions in 
the zip.
   
   You need to rebase your branch on master. Then you will get the same result 
as the failing build checks.
   
   ```suggestion
           CacheUtils.unzip(cachedZip.toPath(), restorationPath, 
cacheConfig.isPreservePermissions());
   ```



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