Fixes
This commit is contained in:
parent
0e66875d27
commit
56a2a52bdd
|
|
@ -39,9 +39,9 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build-player": "$npm_node_execpath build-player.js",
|
"build-player": "$npm_node_execpath build-player.js",
|
||||||
"build-server": "babel --source-maps --out-dir lib/ src/",
|
"build-server": "babel --source-maps --loose es6.destructuring,es6.forOf --out-dir lib/ src/",
|
||||||
"postinstall": "./postinstall.sh",
|
"postinstall": "./postinstall.sh",
|
||||||
"server-dev": "babel --watch --source-maps --out-dir lib/ src/"
|
"server-dev": "babel --watch --source-maps --loose es6.destructuring,es6.forOf --out-dir lib/ src/"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"coffee-script": "^1.9.2"
|
"coffee-script": "^1.9.2"
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,27 @@
|
||||||
import { FileStore } from './filestore';
|
import { FileStore } from './filestore';
|
||||||
import { DatabaseStore } from './dbstore';
|
import { DatabaseStore } from './dbstore';
|
||||||
import Config from '../config';
|
import Config from '../config';
|
||||||
|
import Promise from 'bluebird';
|
||||||
|
|
||||||
const CHANNEL_STORE = loadChannelStore();
|
var CHANNEL_STORE = null;
|
||||||
|
|
||||||
|
export function init() {
|
||||||
|
CHANNEL_STORE = loadChannelStore();
|
||||||
|
}
|
||||||
|
|
||||||
export function load(channelName) {
|
export function load(channelName) {
|
||||||
|
if (CHANNEL_STORE === null) {
|
||||||
|
return Promise.reject(new Error('ChannelStore not initialized yet'));
|
||||||
|
}
|
||||||
|
|
||||||
return CHANNEL_STORE.load(channelName);
|
return CHANNEL_STORE.load(channelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function save(channelName, data) {
|
export function save(channelName, data) {
|
||||||
|
if (CHANNEL_STORE === null) {
|
||||||
|
return Promise.reject(new Error('ChannelStore not initialized yet'));
|
||||||
|
}
|
||||||
|
|
||||||
return CHANNEL_STORE.save(channelName, data);
|
return CHANNEL_STORE.save(channelName, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,14 +45,14 @@ export class DatabaseStore {
|
||||||
return queryAsync(QUERY_CHANNEL_DATA, [rows[0].id]);
|
return queryAsync(QUERY_CHANNEL_DATA, [rows[0].id]);
|
||||||
}).then(rows => {
|
}).then(rows => {
|
||||||
const data = {};
|
const data = {};
|
||||||
for (const row of rows) {
|
rows.forEach(row => {
|
||||||
try {
|
try {
|
||||||
data[row.key] = JSON.parse(row.value);
|
data[row.key] = JSON.parse(row.value);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.errlog.log(`Channel data for channel "${channelName}", ` +
|
Logger.errlog.log(`Channel data for channel "${channelName}", ` +
|
||||||
`key "${row.key}" is invalid: ${e}`);
|
`key "${row.key}" is invalid: ${e}`);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
|
|
@ -68,7 +68,7 @@ export class DatabaseStore {
|
||||||
let rowCount = 0;
|
let rowCount = 0;
|
||||||
const id = rows[0].id;
|
const id = rows[0].id;
|
||||||
const substitutions = [];
|
const substitutions = [];
|
||||||
for (const key of Object.keys(data)) {
|
for (const key in data) {
|
||||||
if (typeof data[key] === 'undefined') {
|
if (typeof data[key] === 'undefined') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,9 @@ function queryAsync(query, substitutions) {
|
||||||
|
|
||||||
function fixOldChandump(data) {
|
function fixOldChandump(data) {
|
||||||
const converted = {};
|
const converted = {};
|
||||||
for (const key of EXPECTED_KEYS) {
|
EXPECTED_KEYS.forEach(key => {
|
||||||
converted[key] = data[key];
|
converted[key] = data[key];
|
||||||
}
|
});
|
||||||
|
|
||||||
if (data.queue) {
|
if (data.queue) {
|
||||||
converted.playlist = {
|
converted.playlist = {
|
||||||
|
|
|
||||||
|
|
@ -556,7 +556,8 @@ module.exports.listStats = function (callback) {
|
||||||
|
|
||||||
/* Misc */
|
/* Misc */
|
||||||
module.exports.loadAnnouncement = function () {
|
module.exports.loadAnnouncement = function () {
|
||||||
if (!Server.getServer()) {
|
// Temporary workaround
|
||||||
|
if (!Server.getServer || !Server.getServer()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ const VERSION = require("../package.json").version;
|
||||||
var singleton = null;
|
var singleton = null;
|
||||||
var Config = require("./config");
|
var Config = require("./config");
|
||||||
var Promise = require("bluebird");
|
var Promise = require("bluebird");
|
||||||
|
import * as ChannelStore from './channel-storage/channelstore';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init: function () {
|
init: function () {
|
||||||
|
|
@ -56,6 +57,7 @@ var Server = function () {
|
||||||
var Database = require("./database");
|
var Database = require("./database");
|
||||||
self.db = Database;
|
self.db = Database;
|
||||||
self.db.init();
|
self.db.init();
|
||||||
|
ChannelStore.init();
|
||||||
|
|
||||||
// webserver init -----------------------------------------------------
|
// webserver init -----------------------------------------------------
|
||||||
self.express = express();
|
self.express = express();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue