From: David ‘Bombe’ Roden Date: Fri, 22 Jan 2010 21:22:45 +0000 (+0100) Subject: Check projects for duplicate file entries. X-Git-Tag: 0.9~12 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a8f9077b9c46646ace7c8a665f5085830cad6f81;p=jSite.git Check projects for duplicate file entries. --- 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; }