X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fapplication%2FProjectInserter.java;h=7256bbeb8fe68a36d62d3cc261bab3d796acde21;hb=3b53ea254e50420df8fe2ea9121855d600560f88;hp=3d2457bd872b11a3b3e8b05ab59998c6a993de13;hpb=b697c40d075280114882b149a9d1f068766294c5;p=jSite.git diff --git a/src/de/todesbaum/jsite/application/ProjectInserter.java b/src/de/todesbaum/jsite/application/ProjectInserter.java index 3d2457b..7256bbe 100644 --- a/src/de/todesbaum/jsite/application/ProjectInserter.java +++ b/src/de/todesbaum/jsite/application/ProjectInserter.java @@ -54,6 +54,9 @@ import de.todesbaum.util.io.StreamCopier; */ public class ProjectInserter implements FileScannerListener, Runnable { + /** Random number for FCP instances. */ + private static final int random = (int) (Math.random() * Integer.MAX_VALUE); + /** Counter for FCP connection identifier. */ private static int counter = 0; @@ -366,7 +369,7 @@ public class ProjectInserter implements FileScannerListener, Runnable { List files = fileScanner.getFiles(); /* create connection to node */ - Connection connection = freenetInterface.getConnection("project-insert-" + counter++); + Connection connection = freenetInterface.getConnection("project-insert-" + random + counter++); boolean connected = false; Throwable cause = null; try { @@ -391,7 +394,9 @@ public class ProjectInserter implements FileScannerListener, Runnable { int edition = project.getEdition(); String dirURI = "USK@" + project.getInsertURI() + "/" + project.getPath() + "/" + edition + "/"; ClientPutComplexDir putDir = new ClientPutComplexDir("dir-" + counter++, dirURI); - putDir.setDefaultName(project.getIndexFile()); + if ((project.getIndexFile() != null) && (project.getIndexFile().length() > 0)) { + putDir.setDefaultName(project.getIndexFile()); + } putDir.setVerbosity(Verbosity.ALL); putDir.setMaxRetries(-1); for (String filename : files) { @@ -421,6 +426,7 @@ public class ProjectInserter implements FileScannerListener, Runnable { System.out.println(message); } if (!finished) { + @SuppressWarnings("null") String messageName = message.getName(); if ("URIGenerated".equals(messageName)) { finalURI = message.get("URI"); @@ -442,6 +448,7 @@ public class ProjectInserter implements FileScannerListener, Runnable { /* post-insert work */ fireProjectInsertFinished(success, disconnected ? new IOException("Connection terminated") : null); if (success) { + @SuppressWarnings("null") String editionPart = finalURI.substring(finalURI.lastIndexOf('/') + 1); int newEdition = Integer.parseInt(editionPart); project.setEdition(newEdition);