cziegeler 2003/02/07 03:22:27 Modified: src/java/org/apache/cocoon/components/source/impl FileSource.java Log: Close the stream only once - this avoids accidentally deleting the already stored file Revision Changes Path 1.12 +19 -17 xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/FileSource.java Index: FileSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/FileSource.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- FileSource.java 6 Feb 2003 12:19:46 -0000 1.11 +++ FileSource.java 7 Feb 2003 11:22:27 -0000 1.12 @@ -116,24 +116,26 @@ } public void close() throws IOException { - super.close(); - - try { - // Delete destination file - if (this.source.getFile().exists()) { - this.source.getFile().delete(); - } - // Rename temp file to destination file - tmpFile.renameTo(this.source.getFile()); - - } finally { - // Ensure temp file is deleted, ie lock is released. - // If there was a failure above, written data is lost. - if (tmpFile.exists()) { - tmpFile.delete(); + if (!this.isClosed) { + super.close(); + try { + // Delete destination file + if (this.source.getFile().exists()) { + this.source.getFile().delete(); + } + // Rename temp file to destination file + tmpFile.renameTo(this.source.getFile()); + + } finally { + // Ensure temp file is deleted, ie lock is released. + // If there was a failure above, written data is lost. + if (tmpFile.exists()) { + tmpFile.delete(); + } + this.isClosed = true; } - this.isClosed = true; } + } public boolean canCancel() {
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]