提交 9a631581 编写于 作者: J Jesse Glick

AtomicFileWriter.commit should use Util.deleteFile so as to get a more...

AtomicFileWriter.commit should use Util.deleteFile so as to get a more meaningful error message in case the deletion fails.
The following is not helpful in terms of diagnosing the root problem:
java.io.IOException: Unable to delete /…/jobs/demo/builds/…/workflow/3.xml
	at hudson.util.AtomicFileWriter.commit(AtomicFileWriter.java:112)
	at hudson.XmlFile.write(XmlFile.java:179)
	at org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage.saveActions(SimpleXStreamFlowNodeStorage.java:106)
	at …
上级 68b383e0
......@@ -23,6 +23,7 @@
*/
package hudson.util;
import hudson.Util;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
......@@ -107,9 +108,13 @@ public class AtomicFileWriter extends Writer {
public void commit() throws IOException {
close();
if(destFile.exists() && !destFile.delete()) {
tmpFile.delete();
throw new IOException("Unable to delete "+destFile);
if (destFile.exists()) {
try {
Util.deleteFile(destFile);
} catch (IOException x) {
tmpFile.delete();
throw x;
}
}
tmpFile.renameTo(destFile);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册