cstamas commented on code in PR #323:
URL: https://github.com/apache/maven-filtering/pull/323#discussion_r2832777150


##########
src/main/java/org/apache/maven/shared/filtering/FilteringUtils.java:
##########
@@ -330,8 +387,38 @@ public static void copyFile(File from, File to, String 
encoding, FilterWrapper[]
                 }
             }
         }
+        copyFilePermissions(from, to);
+        return true;
+    }
 
+    private static boolean copyIfContentsChanged(File from, File to, String 
encoding, FilterWrapper[] wrappers)
+            throws IOException {
+        setReadWritePermissions(to);
+        boolean copied = false;
+        if (wrappers == null || wrappers.length == 0) {
+            try (CachingOutputStream os = new 
CachingOutputStream(to.toPath())) {
+                Files.copy(from.toPath(), os);
+                copied = os.isModified();
+            }
+        } else {
+            Charset charset = charset(encoding);
+            try (Reader fileReader = Files.newBufferedReader(from.toPath(), 
charset)) {
+                Reader wrapped = fileReader;
+                for (FilterWrapper wrapper : wrappers) {
+                    wrapped = wrapper.getReader(wrapped);
+                }
+                try (CachingWriter writer = new CachingWriter(to.toPath(), 
charset)) {
+                    char[] buffer = new char[COPY_BUFFER_LENGTH];
+                    int nRead;
+                    while ((nRead = wrapped.read(buffer, 0, 
COPY_BUFFER_LENGTH)) >= 0) {
+                        writer.write(buffer, 0, nRead);
+                    }
+                    copied = writer.isModified();
+                }
+            }
+        }
         copyFilePermissions(from, to);

Review Comment:
   nope, i missed at method beginning: _we modify_ perms



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