Check projects for duplicate file entries.
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 22 Jan 2010 21:22:45 +0000 (22:22 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 22 Jan 2010 21:22:45 +0000 (22:22 +0100)
src/de/todesbaum/jsite/application/ProjectInserter.java

index c8c5e93..48fd36b 100644 (file)
@@ -29,6 +29,7 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -435,6 +436,22 @@ public class ProjectInserter implements FileScannerListener, Runnable {
                if (!insert) {
                        checkReport.addIssue("error.no-files-to-insert", true);
                }
+               Set<String> fileNames = new HashSet<String>();
+               for (Entry<String, FileOption> fileOptionEntry : fileOptionEntries) {
+                       FileOption fileOption = fileOptionEntry.getValue();
+                       if (!fileOption.isInsert() && !fileOption.isInsertRedirect()) {
+                               logger.log(Level.FINEST, "Ignoring {0}.", fileOptionEntry.getKey());
+                               continue;
+                       }
+                       String fileName = fileOptionEntry.getKey();
+                       if (fileOption.hasChangedName()) {
+                               fileName = fileOption.getChangedName();
+                       }
+                       logger.log(Level.FINEST, "Adding “{0}” for {1}.", new Object[] { fileName, fileOptionEntry.getKey() });
+                       if (!fileNames.add(fileName)) {
+                               checkReport.addIssue("error.duplicate-file", true, fileName);
+                       }
+               }
                return checkReport;
        }