Don’t ignore exceptions when creating the payload stream but fail the insert.
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 28 Dec 2009 23:39:58 +0000 (00:39 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 28 Dec 2009 23:39:58 +0000 (00:39 +0100)
src/de/todesbaum/jsite/application/ProjectInserter.java
src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java

index 597c237..c6d0f85 100644 (file)
@@ -419,7 +419,12 @@ public class ProjectInserter implements FileScannerListener, Runnable {
                for (String filename : files) {
                        FileEntry fileEntry = createFileEntry(filename, edition, containerFiles);
                        if (fileEntry != null) {
-                               putDir.addFileEntry(fileEntry);
+                               try {
+                                       putDir.addFileEntry(fileEntry);
+                               } catch (IOException ioe1) {
+                                       fireProjectInsertFinished(false, ioe1);
+                                       return;
+                               }
                        }
                }
 
index 7b9115d..4be7528 100644 (file)
@@ -90,8 +90,10 @@ public class ClientPutComplexDir extends ClientPutDir {
         *
         * @param fileEntry
         *            The file entry to add to the directory
+        * @throws IOException
+        *             if an I/O error occurs when creating the payload stream
         */
-       public void addFileEntry(FileEntry fileEntry) {
+       public void addFileEntry(FileEntry fileEntry) throws IOException {
                if (fileEntry instanceof DirectFileEntry) {
                        if (payloadFile == null) {
                                try {
@@ -114,7 +116,8 @@ public class ClientPutComplexDir extends ClientPutDir {
                                        payloadOutputStream.flush();
                                        fileEntries.add(fileEntry);
                                } catch (IOException ioe1) {
-                                       /* hmm, ignore? */
+                                       payloadFile.delete();
+                                       throw ioe1;
                                } finally {
                                        Closer.close(payloadOutputStream);
                                        Closer.close(payloadInputStream);