提交 21b7c3cd 编写于 作者: K kohsuke

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
上级 dd84fa05
......@@ -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.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册