fix duble error checking

fix whitespace coding convention
This commit is contained in:
aritas1 2012-02-15 15:57:39 +04:00
parent 8bff85cdb2
commit f7d8f68c13
3 changed files with 49 additions and 53 deletions

View file

@ -473,36 +473,36 @@ Example returns:
*/ */
exports.listAllPads = function(callback) exports.listAllPads = function(callback)
{ {
allPads = []; allPads = [];
var defaultGroup = "g.defaultGroupName";
//get all groups
groupManager.listGroups(function (err, groups)
{
groups=groups["groupIDs"];
// if defaultGroup exists add this too, becaus ists not listed in groupManager.listGroups
groupManager.doesGroupExist(defaultGroup, function(err, exists)
{
if(exists)
{
groups.push(defaultGroup);
}
});
for(var group in groups) var defaultGroup = "g.defaultGroupName";
{
groupManager.listPads(groups[group], function(err, pads) //get all groups
{ groupManager.listGroups(function (err, groups)
for(var pad in pads["padIDs"]) {
{ groups=groups["groupIDs"];
allPads.push(pads["padIDs"][pad]); // if defaultGroup exists add this too, becaus ists not listed in groupManager.listGroups
} groupManager.doesGroupExist(defaultGroup, function(err, exists)
}); {
} if(exists)
{
groups.push(defaultGroup);
}
}); });
callback(null, {padIDs: allPads}); for(var group in groups)
{
groupManager.listPads(groups[group], function(err, pads)
{
for(var pad in pads["padIDs"])
{
allPads.push(pads["padIDs"][pad]);
}
});
}
});
callback(null, {padIDs: allPads});
} }
/******************************/ /******************************/

View file

@ -106,29 +106,25 @@ exports.deleteGroup = function(groupID, callback)
db.get("groups", function (err, groups) db.get("groups", function (err, groups)
{ {
if(ERR(err, callback)) return; if(ERR(err, callback)) return;
if(ERR(err, callback)) return; existingGroups = [];
existingGroups = []; if(groups != undefined)
{
if(groups != undefined) for(var key in groups['groups'])
{ {
for(var key in groups['groups']) if(groupID != groups['groups'][key])
{ {
if(groupID != groups['groups'][key]) existingGroups.push(groups['groups'][key]);
{ }
existingGroups.push(groups['groups'][key]);
}
}
} }
}
db.set("groups", {groups: existingGroups}); db.set("groups", {groups: existingGroups});
}); });
db.remove("group2sessions:" + groupID); db.remove("group2sessions:" + groupID);
db.remove("group:" + groupID); db.remove("group:" + groupID);
callback(); callback();
} }
], function(err) ], function(err)
@ -169,10 +165,10 @@ exports.createGroup = function(callback)
if(ERR(err, callback)) return; if(ERR(err, callback)) return;
if(responseGroups != undefined) if(responseGroups != undefined)
{ {
for(var key in responseGroups['groups']) for(var key in responseGroups['groups'])
{ {
existingGroups.push(responseGroups['groups'][key]); existingGroups.push(responseGroups['groups'][key]);
} }
} }
}); });

View file

@ -351,21 +351,21 @@ Pad.prototype.init = function init(text, callback) {
else else
{ {
var firstChangeset = Changeset.makeSplice("\n", 0, 0, exports.cleanText(text)); var firstChangeset = Changeset.makeSplice("\n", 0, 0, exports.cleanText(text));
// if this is a non group pad, add this to the defaultGroup // if this is a non group pad, add this to the defaultGroup
if(_this.id.indexOf("$")==-1) if(_this.id.indexOf("$")==-1)
{ {
groupID = "g.defaultGroupName"; groupID = "g.defaultGroupName";
groupManager.doesGroupExist(groupID, function(err, exists) groupManager.doesGroupExist(groupID, function(err, exists)
{ {
if(!exists) if(!exists)
{ {
db.set("group:" + groupID, {pads: {}}); db.set("group:" + groupID, {pads: {}});
} }
}); });
db.setSub("group:"+groupID, ["pads", _this.id], 1); db.setSub("group:"+groupID, ["pads", _this.id], 1);
} }
_this.appendRevision(firstChangeset, ''); _this.appendRevision(firstChangeset, '');
} }