X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Futil%2Ffreenet%2Ffcp2%2FClientPutComplexDir.java;h=12d963d7b53768b94a3c949b6446ee6973996d74;hb=7bd75673638ec38307005f5cef154116dab30491;hp=237cb1c79f2d3c3a1f2c9f8853cdf758af721493;hpb=81f5fdb642557fe0963cff595b149c4f77bd7bc2;p=jSite.git
diff --git a/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java b/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java
index 237cb1c..12d963d 100644
--- a/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java
+++ b/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java
@@ -1,5 +1,5 @@
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
@@ -34,7 +34,7 @@ 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.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
@@ -42,13 +42,13 @@ public class ClientPutComplexDir extends ClientPutDir {
/** The file entries of this directory. */
private List fileEntries = new ArrayList();
-
+
/** Whether this request has payload. */
private boolean hasPayload = false;
-
+
/** The input streams for the payload. */
private File payloadFile;
-
+
/** The total number of bytes of the payload. */
private long payloadLength = 0;
@@ -66,31 +66,35 @@ public class ClientPutComplexDir extends ClientPutDir {
* @param fileEntry The file entry to add to the directory
*/
public void addFileEntry(FileEntry fileEntry) {
- if (payloadFile == null){
- try {
- payloadFile = File.createTempFile("payload", ".dat");
- payloadFile.deleteOnExit();
- } catch (IOException e) {
+ if (fileEntry instanceof DirectFileEntry) {
+ if (payloadFile == null){
+ try {
+ payloadFile = File.createTempFile("payload", ".dat");
+ payloadFile.deleteOnExit();
+ } catch (IOException e) {
+ }
}
- }
- if (payloadFile != null) {
- InputStream payloadInputStream = ((DirectFileEntry) fileEntry).getDataInputStream();
- FileOutputStream payloadOutputStream = null;
- try {
- payloadOutputStream = new FileOutputStream(payloadFile, true);
- byte[] buffer = new byte[65536];
- int read = 0;
- while ((read = payloadInputStream.read(buffer)) != -1) {
- payloadOutputStream.write(buffer, 0, read);
+ if (payloadFile != null) {
+ InputStream payloadInputStream = ((DirectFileEntry) fileEntry).getDataInputStream();
+ FileOutputStream payloadOutputStream = null;
+ try {
+ payloadOutputStream = new FileOutputStream(payloadFile, true);
+ byte[] buffer = new byte[65536];
+ int read = 0;
+ while ((read = payloadInputStream.read(buffer)) != -1) {
+ payloadOutputStream.write(buffer, 0, read);
+ }
+ payloadOutputStream.flush();
+ fileEntries.add(fileEntry);
+ } catch (IOException ioe1) {
+ /* hmm, ignore? */
+ } finally {
+ Closer.close(payloadOutputStream);
+ Closer.close(payloadInputStream);
}
- payloadOutputStream.flush();
- fileEntries.add(fileEntry);
- } catch (IOException ioe1) {
- /* hmm, ignore? */
- } finally {
- Closer.close(payloadOutputStream);
- Closer.close(payloadInputStream);
}
+ } else {
+ fileEntries.add(fileEntry);
}
}