Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-575

copyDirectory (all overloads) does not maintain file permissions

    XMLWordPrintableJSON

Details

    Description

      I found that permissions (specifically, execute) are not maintained when using copyDirectory. The following test demonstrates the behavior:**

       

      Path sourceDir = Files.createTempDirectory("source-dir");
      String filename = "some-file";
      Path sourceFile = Files.createFile(sourceDir.resolve(filename));
      
      assertThat(sourceFile.toFile().canExecute()).isFalse();
      
      sourceFile.toFile().setExecutable(true);
      
      assertThat(sourceFile.toFile().canExecute()).isTrue();
      
      Path destDir = Files.createTempDirectory("some-empty-destination");
      
      FileUtils.copyDirectory(sourceDir.toFile(), destDir.toFile());
      
      Path destFile = destDir.resolve(filename);
      
      assertThat(destFile.toFile().exists()).isTrue();
      assertThat(destFile.toFile().canExecute()).isTrue(); // fails
      

      Is it working as intended that the permissions are not copied over?

       

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            adamkewley Adam Kewley
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 10m
                10m