From a8f9077b9c46646ace7c8a665f5085830cad6f81 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 22 Jan 2010 22:22:45 +0100 Subject: [PATCH] Check projects for duplicate file entries. --- src/de/todesbaum/jsite/application/ProjectInserter.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/de/todesbaum/jsite/application/ProjectInserter.java b/src/de/todesbaum/jsite/application/ProjectInserter.java index c8c5e93..48fd36b 100644 --- a/src/de/todesbaum/jsite/application/ProjectInserter.java +++ b/src/de/todesbaum/jsite/application/ProjectInserter.java @@ -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 fileNames = new HashSet(); + for (Entry 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; } -- 2.7.4