X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fapplication%2FProject.java;h=fa0b774dccac4f49922d285a46b27277287e0f84;hb=484ca8e1679b9658f05a9e80e38b1ac519b38709;hp=1f5e372c902671ea77655126f052e58aa2700386;hpb=a6bda7a82aa1b2cfd0313fb28d3dcca68ca516c5;p=jSite.git diff --git a/src/de/todesbaum/jsite/application/Project.java b/src/de/todesbaum/jsite/application/Project.java index 1f5e372..fa0b774 100644 --- a/src/de/todesbaum/jsite/application/Project.java +++ b/src/de/todesbaum/jsite/application/Project.java @@ -1,5 +1,5 @@ /* - * jSite - Project.java - Copyright © 2006–2011 David Roden + * jSite - Project.java - Copyright © 2006–2012 David Roden * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software @@ -22,6 +22,7 @@ import java.io.File; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import de.todesbaum.util.mime.DefaultMIMETypes; @@ -419,4 +420,22 @@ public class Project implements Comparable { return "USK@" + requestURI + "/" + path + "/" + (edition + offset) + "/"; } + /** + * Performs some post-processing on the project after it was inserted + * successfully. At the moment it copies the current hashes of all file + * options to the last insert hashes, updating the hashes for the next + * insert. + */ + public void onSuccessfulInsert() { + for (Entry fileOptionEntry : fileOptions.entrySet()) { + FileOption fileOption = fileOptionEntry.getValue(); + if ((fileOption.getCurrentHash() != null) && (fileOption.getCurrentHash().length() > 0) && (!fileOption.getCurrentHash().equals(fileOption.getLastInsertHash()) || fileOption.isForceInsert())) { + fileOption.setLastInsertEdition(edition); + fileOption.setLastInsertHash(fileOption.getCurrentHash()); + fileOption.setLastInsertFilename(fileOption.hasChangedName() ? fileOption.getChangedName() : fileOptionEntry.getKey()); + } + fileOption.setForceInsert(false); + } + } + }