[freenet-cvs] r19269 - trunk/apps/thingamablog/src/net/sf/thingamablog/transport
dieppe at freenetproject.org
dieppe at freenetproject.org
Sun Apr 13 18:43:55 UTC 2008
Author: dieppe
Date: 2008-04-13 18:43:55 +0000 (Sun, 13 Apr 2008)
New Revision: 19269
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
Log:
Hopefully fix the publish process when the node is not local (using
direct method instead disk one)
Modified: trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java 2008-04-13 17:25:56 UTC (rev 19268)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java 2008-04-13 18:43:55 UTC (rev 19269)
@@ -132,12 +132,19 @@
for(Enumeration e = ht.keys() ; e.hasMoreElements() ;) {
Object element = e.nextElement();
File file = (File)element;
- String path = ((String) ht.get(element)).substring(arcPath.length());
- FileEntry fileEntry = createFileEntry(file, edition, path);
- if (fileEntry != null) {
- System.out.println("File to insert : " + fileEntry.getFilename());
- totalBytes += file.length();
- putDir.addFileEntry(fileEntry);
+ long[] fileLength = new long[1];
+ try {
+ InputStream fileEntryInputStream = createFileInputStream(file, fileLength);
+ String path = ((String) ht.get(element)).substring(arcPath.length());
+ FileEntry fileEntry = createDirectFileEntry(file.getName(), fileEntryInputStream, fileLength);
+// FileEntry fileEntry = createDiskFileEntry(file, path);
+ if (fileEntry != null) {
+ System.out.println("File to insert : " + fileEntry.getFilename());
+ totalBytes += fileLength[0];
+ putDir.addFileEntry(fileEntry);
+ }
+ } catch (IOException ex) {
+ logger.log(Level.WARNING, ex.getMessage());
}
}
// If there is an active link set, we publish it
@@ -191,13 +198,24 @@
return success;
}
- private FileEntry createFileEntry(File file, int edition, String path){
+ private FileEntry createDiskFileEntry(File file, String path){
String content = DefaultMIMETypes.guessMIMEType(file.getName());
System.out.println("File path : " + file.getPath());
FileEntry fileEntry = new DiskFileEntry(path + file.getName(), content, file.getPath());
return fileEntry;
}
+ private FileEntry createDirectFileEntry(String filename, InputStream fileEntryInputStream, long[] fileLength){
+ String content = DefaultMIMETypes.guessMIMEType(filename);
+ FileEntry fileEntry = new DirectFileEntry(filename, content, fileEntryInputStream, fileLength[0]);
+ return fileEntry;
+ }
+
+ private InputStream createFileInputStream(File file, long[] length) throws IOException {
+ length[0] = file.length();
+ return new FileInputStream(file);
+ }
+
public void setNode(String hostname, int port) {
this.hostname = hostname;
this.port = port;
More information about the cvs
mailing list