version 0.4.8.1: set maxRetries to -1
[jSite.git] / src / de / todesbaum / jsite / application / ProjectInserter.java
index ced3008..b51dd0c 100644 (file)
@@ -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);
                }
        }