Merge pull request #1925 from ether/move-padlist-init

Move padlist init
This commit is contained in:
John McLear 2013-10-09 11:45:59 -07:00
commit d86d99bc16

View file

@ -37,6 +37,11 @@ var globalPads = {
set: function (name, value) set: function (name, value)
{ {
this[':'+name] = value; this[':'+name] = value;
if(!padList.list.length == 0){ // If we haven't populated the padList.list yet
padList.init();
}
padList.addPad(name); padList.addPad(name);
}, },
remove: function (name) { delete this[':'+name]; } remove: function (name) { delete this[':'+name]; }
@ -85,7 +90,6 @@ var padList = {
} }
}; };
//initialises the allknowing data structure //initialises the allknowing data structure
padList.init();
/** /**
* An array of padId transformations. These represent changes in pad name policy over * An array of padId transformations. These represent changes in pad name policy over
@ -159,6 +163,9 @@ exports.getPad = function(id, text, callback)
exports.listAllPads = function(callback) exports.listAllPads = function(callback)
{ {
if(!padList.list.length == 0){ // If we haven't populated the padList.list yet
padList.init();
}
if(callback != null){ if(callback != null){
callback(null,{padIDs: padList.getPads()}); callback(null,{padIDs: padList.getPads()});
}else{ }else{
@ -224,6 +231,9 @@ exports.isValidPadId = function(padId)
* Removes the pad from database and unloads it. * Removes the pad from database and unloads it.
*/ */
exports.removePad = function(padId){ exports.removePad = function(padId){
if(!padList.list.length == 0){ // If we haven't populated the padList.list yet
padList.init();
}
db.remove("pad:"+padId); db.remove("pad:"+padId);
exports.unloadPad(padId); exports.unloadPad(padId);
padList.removePad(padId); padList.removePad(padId);