arturobernalg commented on code in PR #690:
URL: https://github.com/apache/maven-war-plugin/pull/690#discussion_r4669188281


##########
src/main/java/org/apache/maven/plugins/war/packaging/AbstractWarPackagingTask.java:
##########
@@ -329,9 +329,13 @@ protected boolean copyFile(
         context.addResource(targetFilename);
 
         BasicFileAttributes readAttributes = 
Files.readAttributes(source.toPath(), BasicFileAttributes.class);
+        // A directory source is archived into destination below, so 
destination's content can't be compared
+        // to it directly; fall back to the mtime-only check that was already 
used for directories.
         if (onlyIfModified
                 && destination.lastModified()
-                        >= readAttributes.lastModifiedTime().toMillis()) {
+                        >= readAttributes.lastModifiedTime().toMillis()
+                && (readAttributes.isDirectory()
+                        || 
org.apache.commons.io.FileUtils.contentEquals(source, destination))) {

Review Comment:
   Qualified name: switched to a static import (`import static 
org.apache.commons.io.FileUtils.contentEquals;`) in 989e486, so the call site 
is now just `contentEquals(source, destination)`.
   
   Reading cost: `FileUtils.contentEquals` checks file length first and returns 
immediately on a size mismatch, so the full byte read only happens when the 
sizes already match — the same case where the old code would go on to write 
anyway. It reads nothing extra when sizes already differ.



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