mirror of https://github.com/calzoneman/sync.git
Fixes
This commit is contained in:
parent
0e66875d27
commit
56a2a52bdd
|
@ -39,9 +39,9 @@
|
|||
},
|
||||
"scripts": {
|
||||
"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",
|
||||
"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": {
|
||||
"coffee-script": "^1.9.2"
|
||||
|
|
|
@ -1,14 +1,27 @@
|
|||
import { FileStore } from './filestore';
|
||||
import { DatabaseStore } from './dbstore';
|
||||
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) {
|
||||
if (CHANNEL_STORE === null) {
|
||||
return Promise.reject(new Error('ChannelStore not initialized yet'));
|
||||
}
|
||||
|
||||
return CHANNEL_STORE.load(channelName);
|
||||
}
|
||||
|
||||
export function save(channelName, data) {
|
||||
if (CHANNEL_STORE === null) {
|
||||
return Promise.reject(new Error('ChannelStore not initialized yet'));
|
||||
}
|
||||
|
||||
return CHANNEL_STORE.save(channelName, data);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,14 +45,14 @@ export class DatabaseStore {
|
|||
return queryAsync(QUERY_CHANNEL_DATA, [rows[0].id]);
|
||||
}).then(rows => {
|
||||
const data = {};
|
||||
for (const row of rows) {
|
||||
rows.forEach(row => {
|
||||
try {
|
||||
data[row.key] = JSON.parse(row.value);
|
||||
} catch (e) {
|
||||
Logger.errlog.log(`Channel data for channel "${channelName}", ` +
|
||||
`key "${row.key}" is invalid: ${e}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return data;
|
||||
});
|
||||
|
@ -68,7 +68,7 @@ export class DatabaseStore {
|
|||
let rowCount = 0;
|
||||
const id = rows[0].id;
|
||||
const substitutions = [];
|
||||
for (const key of Object.keys(data)) {
|
||||
for (const key in data) {
|
||||
if (typeof data[key] === 'undefined') {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ function queryAsync(query, substitutions) {
|
|||
|
||||
function fixOldChandump(data) {
|
||||
const converted = {};
|
||||
for (const key of EXPECTED_KEYS) {
|
||||
EXPECTED_KEYS.forEach(key => {
|
||||
converted[key] = data[key];
|
||||
}
|
||||
});
|
||||
|
||||
if (data.queue) {
|
||||
converted.playlist = {
|
||||
|
|
|
@ -556,7 +556,8 @@ module.exports.listStats = function (callback) {
|
|||
|
||||
/* Misc */
|
||||
module.exports.loadAnnouncement = function () {
|
||||
if (!Server.getServer()) {
|
||||
// Temporary workaround
|
||||
if (!Server.getServer || !Server.getServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ const VERSION = require("../package.json").version;
|
|||
var singleton = null;
|
||||
var Config = require("./config");
|
||||
var Promise = require("bluebird");
|
||||
import * as ChannelStore from './channel-storage/channelstore';
|
||||
|
||||
module.exports = {
|
||||
init: function () {
|
||||
|
@ -56,6 +57,7 @@ var Server = function () {
|
|||
var Database = require("./database");
|
||||
self.db = Database;
|
||||
self.db.init();
|
||||
ChannelStore.init();
|
||||
|
||||
// webserver init -----------------------------------------------------
|
||||
self.express = express();
|
||||
|
|
Loading…
Reference in New Issue