From 7bd75673638ec38307005f5cef154116dab30491 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 2 Feb 2008 21:21:16 +0000 Subject: [PATCH] version 0.4.9.5: fix redirect inserting --- src/de/todesbaum/jsite/main/Version.java | 2 +- .../util/freenet/fcp2/ClientPutComplexDir.java | 58 ++++++++++++---------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/de/todesbaum/jsite/main/Version.java b/src/de/todesbaum/jsite/main/Version.java index b2199aa..0deb7c8 100644 --- a/src/de/todesbaum/jsite/main/Version.java +++ b/src/de/todesbaum/jsite/main/Version.java @@ -25,7 +25,7 @@ package de.todesbaum.jsite.main; */ public class Version { - private static final String VERSION = "0.4.9.4"; + private static final String VERSION = "0.4.9.5"; public static final String getVersion() { return VERSION; 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); } } -- 2.7.4