mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-06 00:25:58 +00:00
Update FilePath.delete* to use Util.delete*
This reduces duplication of file deletion strategy code and potentially fixes a regression noted in JENKINS-55448. Signed-off-by: Matt Sicker <boards@gmail.com>
This commit is contained in:
1 parent
4c6160d710
commit
c05d00ad69
1 file changed
+2
-25
@@ -1271,7 +1271,7 @@ public final class FilePath implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public Void invoke(File f, VirtualChannel channel) throws IOException {
|
||||
deleteRecursive(deleting(f));
|
||||
Util.deleteRecursive(deleting(f));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1286,34 +1286,11 @@ public final class FilePath implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public Void invoke(File f, VirtualChannel channel) throws IOException {
|
||||
deleteContentsRecursive(f);
|
||||
Util.deleteContentsRecursive(deleting(f));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteRecursive(File dir) throws IOException {
|
||||
if(!isSymlink(dir))
|
||||
deleteContentsRecursive(dir);
|
||||
try {
|
||||
deleteFile(deleting(dir));
|
||||
} catch (IOException e) {
|
||||
// if some of the child directories are big, it might take long enough to delete that
|
||||
// it allows others to create new files, causing problems like JENKINS-10113
|
||||
// so give it one more attempt before we give up.
|
||||
if(!isSymlink(dir))
|
||||
deleteContentsRecursive(dir);
|
||||
deleteFile(deleting(dir));
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteContentsRecursive(File file) throws IOException {
|
||||
File[] files = file.listFiles();
|
||||
if(files==null)
|
||||
return; // the directory didn't exist in the first place
|
||||
for (File child : files)
|
||||
deleteRecursive(child);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file name portion except the extension.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user