changeset 2:abe0694e9849

replace local_dir with home_dir
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 25 Mar 2019 13:59:13 -0600
parents 75262552dd35
children 1010f557927f
files conf/Init.luan conf/serve_nabble.luan src/global/Site.java src/nabble/model/DbSiteCreator.java src/nabble/model/Init.java src/nabble/model/Lucene.java src/nabble/model/SiteImpl.java
diffstat 7 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/conf/Init.luan	Thu Mar 21 19:27:36 2019 -0600
+++ b/conf/Init.luan	Mon Mar 25 13:59:13 2019 -0600
@@ -1,6 +1,8 @@
 java()
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
+local Io = require "luan:Io.luan"
+local uri = Io.uri or error()
 local MailHome = require "java:fschmidt.util.mail.MailHome"
 local System = require "java:java.lang.System"
 local Logging = require "luan:logging/Logging.luan"
@@ -20,7 +22,7 @@
 
 Init.poolSize = 130
 
-Init.local_dir = "local/"
+Init.home_dir = uri( uri("classpath:nabble").to_string() ).parent().parent().to_string().."/"
 
 -- for now
 local smtp = MailHome.getSmtpServer("mail.smtp2go.com","dev@singlesushi.com","FB4dating")
--- a/conf/serve_nabble.luan	Thu Mar 21 19:27:36 2019 -0600
+++ b/conf/serve_nabble.luan	Mon Mar 25 13:59:13 2019 -0600
@@ -109,7 +109,7 @@
 	
 	jetty.addBadBotFilter(context, { max = "10" });
 	
-	jetty.addCachingFilter(context, { dir = Init.local_dir.."cache", hasDelayedDelete = "true", acceptEncoding = "gzip" });
+	jetty.addCachingFilter(context, { dir = Init.home_dir.."local/cache", hasDelayedDelete = "true", acceptEncoding = "gzip" });
 	local FileHandler = require "java:cachingfilter.FileHandler"
 	FileHandler.factory = FileHandler.mappedOrIoFile;
 	
@@ -118,7 +118,7 @@
 	add_contexts(jetty)
 	
 	-- /backups folder
-	context = jetty.newFolderContext("/backups", Init.local_dir.."schemas", { "/*" }, false);
+	context = jetty.newFolderContext("/backups", Init.home_dir.."local/schemas", { "/*" }, false);
 	
 	local log
 	if log_to_console then
--- a/src/global/Site.java	Thu Mar 21 19:27:36 2019 -0600
+++ b/src/global/Site.java	Mon Mar 25 13:59:13 2019 -0600
@@ -78,7 +78,7 @@
 
 	static {
 		try {
-			String localDir = (String)Init.get("local_dir");
+			String localDir = (String)Init.get("home_dir")+"local/";
 			dir1 = FSDirectory.open(new File(localDir+"lucene_raw"));
 			dir2 = FSDirectory.open(new File(localDir+"lucene_global"));
 		} catch(IOException e) {
--- a/src/nabble/model/DbSiteCreator.java	Thu Mar 21 19:27:36 2019 -0600
+++ b/src/nabble/model/DbSiteCreator.java	Mon Mar 25 13:59:13 2019 -0600
@@ -23,7 +23,11 @@
 public final class DbSiteCreator {
 	private static final Logger logger = LoggerFactory.getLogger(DbSiteCreator.class);
 
-	private static final File siteSchemaFile = new File("src/nabble/data/site.schema");
+	private static final File siteSchemaFile;
+	static {
+		String homeDir = (String)Init.get("home_dir");
+		siteSchemaFile = new File(homeDir+"src/nabble/data/site.schema");
+	}
 
 	static Site restoreSiteToOldId(File file) {
 		SiteKey siteKey;
--- a/src/nabble/model/Init.java	Thu Mar 21 19:27:36 2019 -0600
+++ b/src/nabble/model/Init.java	Mon Mar 25 13:59:13 2019 -0600
@@ -152,7 +152,7 @@
 
 	public static final boolean hasDaemons = nabble.utils.Jetty.isJetty;
 
-	public static final String tempDir = (String)Init.get("local_dir")+"temp/"; // General purpose folder
+	public static final String tempDir = (String)Init.get("home_dir")+"local/temp/"; // General purpose folder
 
 	public static final int quotedLinesToHide = Init.get("quotedLinesToHide",10);
 
--- a/src/nabble/model/Lucene.java	Thu Mar 21 19:27:36 2019 -0600
+++ b/src/nabble/model/Lucene.java	Mon Mar 25 13:59:13 2019 -0600
@@ -408,8 +408,8 @@
 	static {
 		logger.info("Starting search server");
 		Init.luceneStarted = true;
-		String localDir = (String)Init.get("local_dir");
-		String luceneDir = localDir + "lucene/";
+		String homeDir = (String)Init.get("home_dir");
+		String luceneDir = homeDir + "local/lucene/";
 		File dirFile = new File(luceneDir);
 		nodeIndex = new IndexCache<Long>(dirFile,analyzer,nodeIndexVersion,builder);
 	}
--- a/src/nabble/model/SiteImpl.java	Thu Mar 21 19:27:36 2019 -0600
+++ b/src/nabble/model/SiteImpl.java	Mon Mar 25 13:59:13 2019 -0600
@@ -1062,7 +1062,7 @@
 	}
 
 	private static final String SALT = "zDf3s";
-	private static final File schemaDir = new File((String)Init.get("local_dir")+"schemas/");
+	private static final File schemaDir = new File((String)Init.get("home_dir")+"local/schemas/");
 
 	private static File getBackupFile(long siteId) {
 		int hash = Math.abs(( SALT + siteId ).hashCode());