roxspring commented on a change in pull request #28:
URL: https://github.com/apache/maven-shared-utils/pull/28#discussion_r430700704



##########
File path: src/main/java/org/apache/maven/shared/utils/io/FileUtils.java
##########
@@ -1810,34 +1816,101 @@ public static void copyFile( @Nonnull File from, 
@Nonnull File to, @Nullable Str
                                  @Nullable FilterWrapper[] wrappers, boolean 
overwrite )
         throws IOException
     {
-        if ( wrappers != null && wrappers.length > 0 )
+        if ( wrappers == null || wrappers.length == 0 )
         {
-            
-            if ( encoding == null || encoding.isEmpty() ) 
+            if ( overwrite || to.lastModified() < from.lastModified() )
+            {
+                copyFile( from, to );
+            }
+        }
+        else
+        {
+            if ( encoding == null || encoding.isEmpty() )
             {
                 encoding = Charset.defaultCharset().name();
             }
-            
+
             // buffer so it isn't reading a byte at a time!
             try ( Reader fileReader =
-                new BufferedReader( new InputStreamReader( new 
FileInputStream( from ), encoding ) );
-                            Writer fileWriter = new OutputStreamWriter( new 
FileOutputStream( to ), encoding ) )
+                    new BufferedReader( new InputStreamReader( new 
FileInputStream( from ), encoding ) ) )

Review comment:
       Done.

##########
File path: src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
##########
@@ -441,9 +449,300 @@ public void copyFile1()
             testFile1.lastModified() == destination.lastModified());*/
     }
 
+    private static long MILLIS_PER_DAY = 24 * 60 * 60 * 1000L;

Review comment:
       Happy to use `TimeUnit.DAYS.toMillis(1)` instead. Assumed `ChronoUnit` 
and friends weren't available but had forgotten `TimeUnit`!




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to