diff --git a/core/src/main/java/hudson/util/AtomicFileWriter.java b/core/src/main/java/hudson/util/AtomicFileWriter.java index 65f98b34eab524f95cb617094efc268d4fb2b4f7..25e1a0bd7711dd21ceabe48dc24e220fdd374f2e 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())