Merge branch 'dev'

This commit is contained in:
Calvin Montgomery 2013-06-14 16:21:34 -04:00
commit 0d89c13c05
4 changed files with 10 additions and 3 deletions

View file

@ -27,6 +27,7 @@ var Filter = require("./filter.js").Filter;
var Channel = function(name) { var Channel = function(name) {
Logger.syslog.log("Opening channel " + name); Logger.syslog.log("Opening channel " + name);
this.initialized = false;
this.name = name; this.name = name;
// Initialize defaults // Initialize defaults
@ -135,6 +136,8 @@ Channel.prototype.hasPermission = function(user, key) {
Channel.prototype.loadDump = function() { Channel.prototype.loadDump = function() {
fs.readFile("chandump/" + this.name, function(err, data) { fs.readFile("chandump/" + this.name, function(err, data) {
if(err) { if(err) {
Logger.errlog.log("Failed to open channel dump " + this.name);
Logger.errlog.log(err);
return; return;
} }
try { try {
@ -211,6 +214,7 @@ Channel.prototype.loadDump = function() {
this.css = data.css || ""; this.css = data.css || "";
this.js = data.js || ""; this.js = data.js || "";
this.sendAll("channelCSSJS", {css: this.css, js: this.js}); this.sendAll("channelCSSJS", {css: this.css, js: this.js});
this.initialized = true;
setTimeout(function() { incrementalDump(this); }.bind(this), 300000); setTimeout(function() { incrementalDump(this); }.bind(this), 300000);
} }
catch(e) { catch(e) {
@ -221,6 +225,8 @@ Channel.prototype.loadDump = function() {
} }
Channel.prototype.saveDump = function() { Channel.prototype.saveDump = function() {
if(!this.initialized)
return;
var filts = new Array(this.filters.length); var filts = new Array(this.filters.length);
for(var i = 0; i < this.filters.length; i++) { for(var i = 0; i < this.filters.length; i++) {
filts[i] = this.filters[i].pack(); filts[i] = this.filters[i].pack();

View file

@ -2,7 +2,7 @@
"author": "Calvin Montgomery", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "1.9.4", "version": "1.9.5",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View file

@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
const VERSION = "1.9.4"; const VERSION = "1.9.5";
var fs = require("fs"); var fs = require("fs");
var Logger = require("./logger.js"); var Logger = require("./logger.js");
@ -180,5 +180,6 @@ exports.unload = function(chan) {
if(chan.registered) { if(chan.registered) {
chan.saveDump(); chan.saveDump();
} }
exports.channels[chan.name] = null;
delete exports.channels[chan.name]; delete exports.channels[chan.name];
} }

View file

@ -93,7 +93,7 @@ User.prototype.initCallbacks = function() {
return; return;
data.name = data.name.toLowerCase(); data.name = data.name.toLowerCase();
// Channel already loaded // Channel already loaded
if(data.name in Server.channels) { if(data.name in Server.channels && Server.channels[data.name] != null) {
this.channel = Server.channels[data.name]; this.channel = Server.channels[data.name];
} }
// Channel not loaded // Channel not loaded