From e0b6883a608ec018920aeb216c9abcff0bd955f7 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Wed, 6 Aug 2008 18:13:35 +0000 Subject: [PATCH] added a method to abort. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11284 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/util/AtomicFileWriter.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/src/main/java/hudson/util/AtomicFileWriter.java b/core/src/main/java/hudson/util/AtomicFileWriter.java index 65f98b34ea..25e1a0bd77 100644 --- a/core/src/main/java/hudson/util/AtomicFileWriter.java +++ b/core/src/main/java/hudson/util/AtomicFileWriter.java @@ -49,6 +49,15 @@ public class AtomicFileWriter extends Writer { core.close(); } + /** + * When the write operation failed and you'd like to leave the original file intact, + * you can optionally call this method to clean up a temporary file that was created by this writer. + */ + public void abort() throws IOException { + core.close(); + tmpFile.delete(); + } + public void commit() throws IOException { close(); if(destFile.exists() && !destFile.delete()) -- GitLab