You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/09/06 16:09:56 UTC

[commons-io] branch master updated: [IO-575] copyDirectory (all overloads) does not maintain file (#379)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
     new c8e7b467 [IO-575] copyDirectory (all overloads) does not maintain file (#379)
c8e7b467 is described below

commit c8e7b467794a0173409752933085ae20e15bf1ef
Author: Gary Gregory <ga...@users.noreply.github.com>
AuthorDate: Tue Sep 6 09:09:50 2022 -0700

    [IO-575] copyDirectory (all overloads) does not maintain file (#379)
    
    permissions
    
    Add a test
    
    Co-authored-by: Gary Gregory <gg...@rocketsoftware.com>
---
 .../java/org/apache/commons/io/FileUtilsTest.java  | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/test/java/org/apache/commons/io/FileUtilsTest.java b/src/test/java/org/apache/commons/io/FileUtilsTest.java
index 032a192a..6aa926e6 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsTest.java
@@ -1615,6 +1615,28 @@ public class FileUtilsTest extends AbstractTempDirTest {
         assertTrue(src.exists());
     }
 
+    @Test
+    public void testIO575() throws IOException {
+        final Path sourceDir = Files.createTempDirectory("source-dir");
+        final String filename = "some-file";
+        final Path sourceFile = Files.createFile(sourceDir.resolve(filename));
+
+        assertEquals(SystemUtils.IS_OS_WINDOWS, sourceFile.toFile().canExecute());
+
+        sourceFile.toFile().setExecutable(true);
+
+        assertTrue(sourceFile.toFile().canExecute());
+
+        final Path destDir = Files.createTempDirectory("some-empty-destination");
+
+        FileUtils.copyDirectory(sourceDir.toFile(), destDir.toFile());
+
+        final Path destFile = destDir.resolve(filename);
+
+        assertTrue(destFile.toFile().exists());
+        assertTrue(destFile.toFile().canExecute());
+    }
+
     @Test
     public void testIsDirectory() throws IOException {
         assertFalse(FileUtils.isDirectory(null));