X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Futil%2Ffreenet%2Ffcp2%2FClientPutComplexDir.java;h=12d963d7b53768b94a3c949b6446ee6973996d74;hb=51eada955ac2bb96649d95421704cbbefb639ba3;hp=d645bb170fe2ccd6be8998baf7d74ff697b13bc5;hpb=85d5c89f25bed4fc3002eaaaa98e7ca4992fa2d6;p=jSite.git
diff --git a/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java b/src/de/todesbaum/util/freenet/fcp2/ClientPutComplexDir.java
index d645bb1..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,32 +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);
- System.out.println("writing " + read + " bytes");
+ 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);
}
}