From 4b9400fa14972809a94feea27fb669d99e28263c Mon Sep 17 00:00:00 2001 From: echicken <> Date: Tue, 12 May 2015 20:18:03 +0000 Subject: [PATCH] Cleaned up some DB init thingies. --- xtrn/syncwall/service.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/xtrn/syncwall/service.js b/xtrn/syncwall/service.js index f7eb95f1f3..b49f28dd48 100644 --- a/xtrn/syncwall/service.js +++ b/xtrn/syncwall/service.js @@ -125,21 +125,27 @@ var init = function() { for(var h = 0; h < historyFiles.length; h++) historyFiles[h] = httpPath + "/" + file_getname(historyFiles[h]); var months = jsonClient.read(dbName, "MONTHS", 1); - if(!months) - jsonClient.write(dbName, "MONTHS", historyFiles, 2); + if(!months) { + months = historyFiles; + jsonClient.write(dbName, "MONTHS", months, 2); + } for(var h = 0; h < historyFiles.length; h++) { if(months.indexOf(historyFiles[h]) < 0) jsonClient.push(dbName, "MONTHS", historyFiles[h], 2); } users = jsonClient.read(dbName, "USERS", 1); - if(!users) - jsonClient.write(dbName, "USERS", [ usr.alias ], 2); + if(!users) { + users = [ usr.alias ]; + jsonClient.write(dbName, "USERS", users, 2); + } jsonClient.subscribe(dbName, "USERS"); systems = jsonClient.read(dbName, "SYSTEMS", 1); - if(!systems) - jsonClient.write(dbName, "SYSTEMS", [ system.name ], 2); + if(!systems) { + systems = [ system.name ]; + jsonClient.write(dbName, "SYSTEMS", systems, 2); + } jsonClient.subscribe(dbName, "SYSTEMS"); if(!jsonClient.read(dbName, "SEQUENCE.length", 1)) -- GitLab