This also refactors some test calls to mklink into a package-private Util method due to additional tests needing to create junction points.
Signed-off-by: Matt Sicker <boards@gmail.com>
* JENKINS-13128: Preserve copied file permissions and mtime
This fixes a bug where files copied locally do not preserve file permissions or last modification time.
* Use IO utility methods for exception handling
* Fix invalid path exception propagation
* Revert hudson.Util
* Use "Files.createTempDirectory" to create temp directory instead
See SonarQube critical vulnerability squid:S2976 (tag: owasp-a9)
https://next.sonarqube.com/sonarqube/coding_rules#rule_key=squid%3AS2976
* [JENKINS-48227]
Creating a utility "static Path toPath(File file) throws IOException" method,
which wraps InvalidPathException to IOException so that it will be checked.
- also fixed public static final reference
- fixed broken test cases
- added new test cases for toPath() and createTempDir()
* Revert back to public static int
* adjustments due to merges
* Add posix check to determine if Posix FileAttributes should be included
in call to Files.createTempDirectory()
* Remove reference to private element
* Updated to use explicit imports
* Use NIO for FilePath#chmod and IOUtils#mode
* Add tests for NIO mode and chmod implementations
* Add test, remove new method, and update JavaDoc
* Provide system property to use native implementations of chmod and mode
* Revert unrelated whitespace modification
* Don't remove exception from throws and put imports in original location
* Fix broken JavaDoc links
* Ignore file type bits (above 0o7777) in Util#modeToPermission
* Use octal for constants and don't include file type bits
* Revert unnecessary changes to TarArchiverTest
* Add assertion that non-permission bits are ignored by chmod
* Use NIO copy with StandardCopyOption.COPY_ATTRIBUTES in copyToWithPermissions where possible
* Catch InvalidPathException and convert it to IOException
* Create utility method for File#toPath and use File#createDirectories after review
* Remove useless calls to toAbsolutePath and getAbsoluteFile
* Fix typos and use octal for constant after review
* Add test for behavior of copyToWithPermission with special bits
* Always use NIO to detect symlinks
* Make assertion failure message consistent
* Catch NoSuchFileException to keep tests passing
* Make method name more specific and simlify assumption
* Remove obsolete comment and reword the main comment in isSymlink
* Deprecate Kernel32Util#isJunctionOrSymlink
* Use assumptions for junction creation and add messages to assumptions
* Replace deprecated code with recommended alternative
* Add comment explaining call to DosFileAttributes#isOther
* Do not fall back to native code when creating symlinks
* Log FileSystemExceptions when creating symbolic links
* Catch InvalidPathException and rethrow as IOException
* Deprecate Kernel32Utils#createSymbolicLink and #getWin32FileAttributes
* Preserve original logging behavior on Windows and remove useless call to Util#displayIOException
Not fully solved, since the scannedDirs field can still grow to be large, but at least clearing files/dirsNotIncluded.
Also imposing a 5s timeout on the scan regardless of file count, and defining a user-customizable bound.
Instead it was being thrown in a Future that the master did not wait for:
the writing side failed with a closed pipe exception, and this meaningless error was thrown up.
Fixing by waiting for the reading side first, so any error there will be thrown up.
(If there was _also_ an error on the writing side, we would miss it, but typically this will just be the closed stream.)
FilePath#moveAllChildrenTo faild,
when same name directory exist.
change Void to void, recursive_invoke is internal helper function.
thanks review by jglick
The updated version uses the locally cached timestamp, '.timestamp', to set the
'If-Modified-Since' header. 304 Not Modified responses are dealt with by
aborting the installation.