X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fapplication%2FProjectInserter.java;h=b51dd0c715ba13d739a6f70912d9492a034ca48b;hb=refs%2Ftags%2F0.4.8.1;hp=ced300820a461372644e51e8ae84495eedba7403;hpb=e4f461213da0e30faf9e9eb2e97626abff320618;p=jSite.git diff --git a/src/de/todesbaum/jsite/application/ProjectInserter.java b/src/de/todesbaum/jsite/application/ProjectInserter.java index ced3008..b51dd0c 100644 --- a/src/de/todesbaum/jsite/application/ProjectInserter.java +++ b/src/de/todesbaum/jsite/application/ProjectInserter.java @@ -59,7 +59,6 @@ public class ProjectInserter implements FileScannerListener, Runnable { protected Project project; private FileScanner fileScanner; protected final Object lockObject = new Object(); - private int maxRetries = 99999; public void addInsertListener(InsertListener insertListener) { insertListeners.add(insertListener); @@ -117,14 +116,6 @@ public class ProjectInserter implements FileScannerListener, Runnable { this.freenetInterface = freenetInterface; } - /** - * @param maxRetries - * The maxRetries to set. - */ - public void setMaxRetries(int maxRetries) { - this.maxRetries = maxRetries; - } - public void start() { fileScanner = new FileScanner(project); fileScanner.addFileScannerListener(this); @@ -266,12 +257,12 @@ public class ProjectInserter implements FileScannerListener, Runnable { createContainers(files, containers, containerFiles); /* collect files */ - int edition = ((EditionProject) project).getEdition(); + int edition = project.getEdition(); String dirURI = "freenet:USK@" + project.getInsertURI() + "/" + project.getPath() + "/" + edition + "/"; ClientPutComplexDir putDir = new ClientPutComplexDir("dir-" + counter++, dirURI); putDir.setDefaultName(project.getIndexFile()); putDir.setVerbosity(Verbosity.ALL); - putDir.setMaxRetries(maxRetries); + putDir.setMaxRetries(-1); for (String filename: files) { FileEntry fileEntry = createFileEntry(filename, edition, containerFiles); if (fileEntry != null) { @@ -288,6 +279,7 @@ public class ProjectInserter implements FileScannerListener, Runnable { } /* parse progress and success messages */ + String finalURI = null; boolean success = false; boolean finished = false; boolean disconnected = false; @@ -300,7 +292,8 @@ public class ProjectInserter implements FileScannerListener, Runnable { if (!finished) { String messageName = message.getName(); if ("URIGenerated".equals(messageName)) { - fireProjectURIGenerated(message.get("URI")); + finalURI = message.get("URI"); + fireProjectURIGenerated(finalURI); } if ("SimpleProgress".equals(messageName)) { int total = Integer.parseInt(message.get("Total")); @@ -318,9 +311,9 @@ public class ProjectInserter implements FileScannerListener, Runnable { /* post-insert work */ fireProjectInsertFinished(success, disconnected ? new IOException("Connection terminated") : null); if (success) { - if (project instanceof EditionProject) { - ((EditionProject) project).setEdition(edition + 1); - } + String editionPart = finalURI.substring(finalURI.lastIndexOf('/') + 1); + int newEdition = Integer.parseInt(editionPart); + project.setEdition(newEdition); } }