mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-08 01:26:03 +00:00
fixed #585 "Hudson follows symlinks when deleting"
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3474 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
dd84fa05ad
commit
21b7c3cd71
1 file changed
+31
-1
@@ -143,10 +143,40 @@ public class Util {
|
||||
}
|
||||
|
||||
public static void deleteRecursive(File dir) throws IOException {
|
||||
deleteContentsRecursive(dir);
|
||||
if(!isSymlink(dir))
|
||||
deleteContentsRecursive(dir);
|
||||
deleteFile(dir);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Checks if the given file represents a symlink.
|
||||
*/
|
||||
//Taken from http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.java?view=markup
|
||||
public boolean isSymlink(File file) throws IOException {
|
||||
File parent = file.getParentFile();
|
||||
File canonicalFile = file.getCanonicalFile();
|
||||
|
||||
return parent != null
|
||||
&& (!canonicalFile.getName().equals(file.getName()) || !canonicalFile.getPath().startsWith(
|
||||
parent.getCanonicalPath()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new temporary directory.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user