mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-06 00:25:58 +00:00
[JENKINS-44657] Move sub-job's buildsdir when outside of itemrootdir (#2932)
* A test to verify JENKINS-44657 is working in core * [JENKINS-44657] Move sub-job's buildsdir when outside of itemrootdir. * [JENKINS-44657] Fix UsageStatisticsTest Because we've added a test dependency that affects it. * [JENKINS-44657] Normalize the path before comparing * [JENKINS-44657] Use MockFolder instead of folders-plugin for tests * [JENKINS-44657] Document and annotate isDefaultBuildDir * [JENKINS-44657] isDescendant doesn't throw IOException any more * [JENKINS-44657] catch InvalidPathException and rethrow as IOException
This commit is contained in:
1 parent
39dfa055b0
commit
3adfed4b06
5 files changed
+222
-3
No files matched your search
@@ -567,6 +567,25 @@ public class Util {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A check if a file path is a descendant of a parent path
|
||||
* @param forParent the parent the child should be a descendant of
|
||||
* @param potentialChild the path to check
|
||||
* @return true if so
|
||||
* @throws IOException for invalid paths
|
||||
* @since FIXME
|
||||
* @see InvalidPathException
|
||||
*/
|
||||
public static boolean isDescendant(File forParent, File potentialChild) throws IOException {
|
||||
try {
|
||||
Path child = potentialChild.getAbsoluteFile().toPath().normalize();
|
||||
Path parent = forParent.getAbsoluteFile().toPath().normalize();
|
||||
return child.startsWith(parent);
|
||||
} catch (InvalidPathException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new temporary directory.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user