X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Futil%2Ffreenet%2Ffcp2%2FClientPutComplexDir.java;h=d72f2c120f598b731e7a2529e1e39df37c47af6f;hb=953de352675a4ad91fe307d816a4ea7780c94274;hp=1f6a43b7db6e51fcb0e32d7001b9acc49bef8245;hpb=6dfface585b41b2c2a43eb249c581cdab0b308f4;p=jSite.git diff --git a/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java b/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java index 1f6a43b..d72f2c1 100644 --- a/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java +++ b/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java @@ -1,6 +1,5 @@ /* - * todesbaum-lib - - * Copyright (C) 2006 David Roden + * jSite - ClientPutComplexDir.java - Copyright © 2006–2012 David Roden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,13 +31,13 @@ import java.util.List; import de.todesbaum.util.io.Closer; /** - * Implementation of the ClientPutComplexDir command. This - * command can be used to insert directories that do not exist on disk. + * Implementation of the ClientPutComplexDir command. This command + * can be used to insert directories that do not exist on disk. * * @author David Roden <droden@gmail.com> * @version $Id$ */ -public class ClientPutComplexDir extends ClientPutDir { +public class ClientPutComplexDir extends ClientPutDir { /** The file entries of this directory. */ private List fileEntries = new ArrayList(); @@ -56,9 +55,13 @@ public class ClientPutComplexDir extends ClientPutDir { private final String tempDirectory; /** - * Creates a new ClientPutComplexDir command with the specified identifier and URI. - * @param identifier The identifier of the command - * @param uri The URI of the command + * Creates a new ClientPutComplexDir command with the specified + * identifier and URI. + * + * @param identifier + * The identifier of the command + * @param uri + * The URI of the command */ public ClientPutComplexDir(String identifier, String uri) { this(identifier, uri, null); @@ -83,15 +86,20 @@ public class ClientPutComplexDir extends ClientPutDir { /** * Adds a file to the directory inserted by this request. - * @param fileEntry The file entry to add to the directory + * + * @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){ + if (payloadFile == null) { try { payloadFile = File.createTempFile("payload", ".dat", (tempDirectory != null) ? new File(tempDirectory) : null); payloadFile.deleteOnExit(); } catch (IOException e) { + /* ignore. */ } } if (payloadFile != null) { @@ -107,7 +115,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); @@ -125,7 +134,7 @@ public class ClientPutComplexDir extends ClientPutDir { protected void write(Writer writer) throws IOException { super.write(writer); int fileIndex = 0; - for (FileEntry fileEntry: fileEntries) { + for (FileEntry fileEntry : fileEntries) { writer.write("Files." + fileIndex + ".Name=" + fileEntry.getFilename() + LINEFEED); if (fileEntry.getContentType() != null) { writer.write("Files." + fileIndex + ".Metadata.ContentType=" + fileEntry.getContentType() + LINEFEED);