changeset 38:04d4c291484b

handle missing schema
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 11 Jul 2020 21:30:58 -0600
parents 40e282462f2e
children b5d56f522ea3
files src/nabble/model/SiteGlobal.java
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/nabble/model/SiteGlobal.java	Wed Jul 08 21:05:15 2020 -0600
+++ b/src/nabble/model/SiteGlobal.java	Sat Jul 11 21:30:58 2020 -0600
@@ -223,7 +223,7 @@
 	private static final boolean deleteInactiveSites = Init.hasDaemons && Init.get("deleteInactiveSites",false);
 	private static final int daysToDeletion = Init.get("daysToDeletion",30);
 
-	private static void deleteInactiveSites() {
+	public static void deleteInactiveSites() {
 		logger.error("Starting deleteInactiveSites");
 		List<SiteGlobal> sitesToDelete = new ArrayList<SiteGlobal>();
 		try {
@@ -285,8 +285,13 @@
 		for( SiteGlobal siteGlobal : sitesToDelete ) {
 			try {
 				Site site = siteGlobal.site();
-				logger.error("Deleting inactive site ID=" + site.getId() + " (" + site.getRootNode().getSubject() + " / " + site.getRootNode().getDescendantCount() + " nodes)");
-				site.delete();
+				if( site==null ) {
+					logger.error("No site found for site ID=" + siteGlobal.siteKey.getId() + " - deleting from site_global");
+					siteGlobal.getDbRecord().delete();
+				} else {
+					logger.error("Deleting inactive site ID=" + site.getId() + " (" + site.getRootNode().getSubject() + " / " + site.getRootNode().getDescendantCount() + " nodes)");
+					site.delete();
+				}
 			} catch(UpdatingException e) {
 				logger.error("Couldn't delete inactive site: " + e);
 			} catch(RuntimeException e) {