You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/07/26 17:39:07 UTC

[GitHub] [maven-shared-utils] kwin opened a new pull request, #110: [MSHARED-1112] Test case for NoSuchFileException while copying symbolic

kwin opened a new pull request, #110:
URL: https://github.com/apache/maven-shared-utils/pull/110

   link with relative non-existing target


-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven-shared-utils] michael-o commented on pull request #110: [MSHARED-1112] Test case for NoSuchFileException while copying symbolic

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #110:
URL: https://github.com/apache/maven-shared-utils/pull/110#issuecomment-1196394271

   From my PoV, it should mimic [`cp(1)`](https://www.freebsd.org/cgi/man.cgi?query=cp&sektion=1&manpath=freebsd-release-ports).


-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven-shared-utils] michael-o commented on pull request #110: [MSHARED-1112] Test case for NoSuchFileException while copying symbolic

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #110:
URL: https://github.com/apache/maven-shared-utils/pull/110#issuecomment-1195829995

   I'll try to look into this this month.


-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven-shared-utils] michael-o commented on a diff in pull request #110: [MSHARED-1176] Test case for NoSuchFileException while copying symbolic

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #110:
URL: https://github.com/apache/maven-shared-utils/pull/110#discussion_r1059790215


##########
src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java:
##########
@@ -463,6 +464,43 @@ public void copyFileWithNoFiltersAndLastModifiedDateOfZeroAndNoDestination()
         assertFileContent( to, "Hello World!" );
     }
 
+    @Test
+    public void copyRelativeSymbolicLinkFileWithNonExistingTargetWithNoFiltersAndNoDestination()
+        throws Exception
+    {
+        write(
+            "target.txt",
+            MODIFIED_YESTERDAY,
+            "Hello World!"
+        );
+        // must be a relative symbolic link to existing target
+        Path from = Files.createSymbolicLink( new File(tempFolder.getRoot(), "symLink").toPath(), Paths.get( "target.txt" ) );
+        File to = new File(
+            tempFolder.newFolder( "destDirectory" ),
+            "toSymLink"
+        );
+        // this creates a symlink in a new folder pointing to a non-existing relative target "./target.txt"
+        FileUtils.copyFile( from.toFile(), to, null, (FileUtils.FilterWrapper[]) null );
+
+        // this should not fail
+    }
+
+    @Test
+    public void copySymbolicLinkFileWithNonExistingTargetWithNoFiltersAndNoDestination()
+        throws Exception
+    {
+        // link to non existing target
+        Path from = Files.createSymbolicLink( new File(tempFolder.getRoot(), "symLink").toPath(), Paths.get( "non-existing.txt" ) );
+        File to = new File(
+            tempFolder.getRoot(),
+            "toSymLink"
+        );
+        // this creates a symlink in a new folder pointing to a non-existing relative target "./non-existing.txt"
+        FileUtils.copyFile( from.toFile(), to, null, (FileUtils.FilterWrapper[]) null );

Review Comment:
   directory, not folder



##########
src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java:
##########
@@ -463,6 +464,43 @@ public void copyFileWithNoFiltersAndLastModifiedDateOfZeroAndNoDestination()
         assertFileContent( to, "Hello World!" );
     }
 
+    @Test
+    public void copyRelativeSymbolicLinkFileWithNonExistingTargetWithNoFiltersAndNoDestination()
+        throws Exception
+    {
+        write(
+            "target.txt",
+            MODIFIED_YESTERDAY,
+            "Hello World!"
+        );
+        // must be a relative symbolic link to existing target
+        Path from = Files.createSymbolicLink( new File(tempFolder.getRoot(), "symLink").toPath(), Paths.get( "target.txt" ) );
+        File to = new File(
+            tempFolder.newFolder( "destDirectory" ),
+            "toSymLink"
+        );
+        // this creates a symlink in a new folder pointing to a non-existing relative target "./target.txt"

Review Comment:
   directory, not folder



-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven-shared-utils] kwin commented on a diff in pull request #110: [MSHARED-1176] Test case for NoSuchFileException while copying symbolic

Posted by GitBox <gi...@apache.org>.
kwin commented on code in PR #110:
URL: https://github.com/apache/maven-shared-utils/pull/110#discussion_r1059789495


##########
src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java:
##########
@@ -463,6 +464,43 @@ public void copyFileWithNoFiltersAndLastModifiedDateOfZeroAndNoDestination()
         assertFileContent( to, "Hello World!" );
     }
 
+    @Test
+    public void copyRelativeSymbolicLinkFileWithNonExistingTargetWithNoFiltersAndNoDestination()
+        throws Exception
+    {
+        write(
+            "target.txt",
+            MODIFIED_YESTERDAY,
+            "Hello World!"
+        );
+        // must be a relative symbolic link to existing target
+        Path from = Files.createSymbolicLink( new File(tempFolder.getRoot(), "symLink").toPath(), Paths.get( "target.txt" ) );
+        File to = new File(
+            tempFolder.newFolder( "destDirectory" ),
+            "toSymLink"
+        );
+        // this creates a symlink in a new folder pointing to a non-existing relative target "./target.txt"
+        FileUtils.copyFile( from.toFile(), to, null, (FileUtils.FilterWrapper[]) null );
+
+        // this should not fail
+    }
+
+    @Test
+    public void copySymbolicLinkFileWithNonExistingTargetWithNoFiltersAndNoDestination()
+        throws Exception
+    {
+        // link to non existing target
+        Path from = Files.createSymbolicLink( new File(tempFolder.getRoot(), "symLink").toPath(), Paths.get( "non-existing.txt" ) );
+        File to = new File(
+            tempFolder.getRoot(),
+            "toSymLink"
+        );
+        // this creates a symlink in a new folder pointing to a non-existing relative target "./target.txt"

Review Comment:
   ```suggestion
           // this creates a symlink in a new folder pointing to a non-existing relative target "./non-existing.txt"
   ```



-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven-shared-utils] kwin commented on pull request #110: [MSHARED-1112] Test case for NoSuchFileException while copying symbolic

Posted by GitBox <gi...@apache.org>.
kwin commented on PR #110:
URL: https://github.com/apache/maven-shared-utils/pull/110#issuecomment-1195803655

   Yes, exactly. In this case the target does not (yet) exist. The question is how `FileUtils.copyFile(...)` should behave in that case. 


-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven-shared-utils] kwin commented on pull request #110: [MSHARED-1112] Test case for NoSuchFileException while copying symbolic

Posted by GitBox <gi...@apache.org>.
kwin commented on PR #110:
URL: https://github.com/apache/maven-shared-utils/pull/110#issuecomment-1196321239

   > IMHO copy should also not fail in case the source symlink is broken (which it currently does)
   
   I added another (failing) test case for this scenario in https://github.com/apache/maven-shared-utils/pull/110/commits/8ff14a538e13399fbc307c6c3d8cf98437104364


-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven-shared-utils] michael-o commented on pull request #110: [MSHARED-1112] Test case for NoSuchFileException while copying symbolic

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #110:
URL: https://github.com/apache/maven-shared-utils/pull/110#issuecomment-1195863815

   > IMHO copy should also not fail in case the source symlink is broken (which it currently does)
   
   I agree with that. If source leads to nowhere then dest should do to. Fully valid with POSIX.


-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven-shared-utils] kwin commented on pull request #110: [MSHARED-1112] Test case for NoSuchFileException while copying symbolic

Posted by GitBox <gi...@apache.org>.
kwin commented on PR #110:
URL: https://github.com/apache/maven-shared-utils/pull/110#issuecomment-1195840182

   IMHO copy should also not fail in case the source symlink is broken (which it currently does)


-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven-shared-utils] michael-o commented on pull request #110: [MSHARED-1112] Test case for NoSuchFileException while copying symbolic

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #110:
URL: https://github.com/apache/maven-shared-utils/pull/110#issuecomment-1195795922

   Without testing your PR, here is what I see on FreeBSD where `chmod -h` works as expected:
   ```
   mosipov@bsd1srv:/usr/home/mosipov/var/Projekte/maven-shared-utils (master =)
   $ grep chmod /tmp/out
   fchmod(188,0100644)                              = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/org/apache/maven/shared/utils/annotations.xml",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/org/apache/maven/shared/utils/annotations.xml",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/META-INF/LICENSE",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/META-INF/LICENSE",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/META-INF/DEPENDENCIES",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/META-INF/DEPENDENCIES",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/META-INF/NOTICE",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/classes/META-INF/NOTICE",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/directory1/file1.txt",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/directory1/file1.txt",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/directory2/directory21/file21.txt",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/directory2/directory21/file21.txt",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/directory2/file2.txt",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/directory2/file2.txt",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/file.txt",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/directorywalker/file.txt",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/expand/expand_test.zip",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/expand/expand_test.zip",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/targetDir/targetFile.txt",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/targetDir/targetFile.txt",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/fileR.txt",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/fileR.txt",0644) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside",0644) ERR#2 'No such file or directory'
   ```
   and
   ```
   mosipov@bsd1srv:/usr/home/mosipov/var/Projekte/maven-shared-utils (master =)
   $ grep symLinkToFileOnTheOutside /tmp/out
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside",0x7fffdfffc1f0,0x0) ERR#2 'No such file or directory'
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside",{ mode=lrwxr-xr-x ,inode=91832,size=19,blksize=131072 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
   unlink("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside") = 0 (0x0)
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside",0x7fffdfffc460,0x0) ERR#2 'No such file or directory'
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=lrwxr-xr-x ,inode=91158,size=19,blksize=131072 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
   readlink("/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside","../onTheOutside.txt",1025) = 19 (0x13)
   access("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside",F_OK) ERR#2 'No such file or directory'
   symlink("../onTheOutside.txt","/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside") = 0 (0x0)
   fstatat(AT_FDCWD,"/var/mosipov/Projekte/maven-shared-utils/src/test/resources/symlinks/src/symLinkToFileOnTheOutside",{ mode=-rw-r--r-- ,inode=91148,size=839,blksize=4096 },0x0) = 0 (0x0)
   chmod("/var/mosipov/Projekte/maven-shared-utils/target/test-classes/symlinks/src/symLinkToFileOnTheOutside",0644) ERR#2 'No such file or directory'
   ```
   
   The symlink or its target does not exist.


-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven-shared-utils] kwin commented on pull request #110: [MSHARED-1112] Test case for NoSuchFileException while copying symbolic

Posted by GitBox <gi...@apache.org>.
kwin commented on PR #110:
URL: https://github.com/apache/maven-shared-utils/pull/110#issuecomment-1195790542

   @slawekjaranowski This depends on #109 being merged first otherwise the build breaks even before executing the unit test.


-- 
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: issues-unsubscribe@maven.apache.org

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