Repository: ignite Updated Branches: refs/heads/ignite-843-rc2 5110d98dc -> 6fc1865e5
IGNITE-843 Rework cluster remove. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6fc1865e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6fc1865e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6fc1865e Branch: refs/heads/ignite-843-rc2 Commit: 6fc1865e5d11d171fffc01adefbb10712c756f5f Parents: 5110d98 Author: AKuznetsov <[email protected]> Authored: Mon Feb 15 17:55:10 2016 +0700 Committer: AKuznetsov <[email protected]> Committed: Mon Feb 15 17:55:10 2016 +0700 ---------------------------------------------------------------------- .../src/main/js/serve/routes/clusters.js | 8 ++++---- .../src/main/js/serve/routes/igfs.js | 14 ++++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/6fc1865e/modules/control-center-web/src/main/js/serve/routes/clusters.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js index acfb2aa..2674975 100644 --- a/modules/control-center-web/src/main/js/serve/routes/clusters.js +++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js @@ -142,14 +142,14 @@ module.exports.factory = function(_, express, mongo) { let spacesIds = []; - mongo.Cluster.remove(clusterId) - .then(() => mongo.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]})) + mongo.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]}) .then((spaces) => { spacesIds = spaces.map((value) => value._id); - return mongo.Cache.update(mongo.Cache.update({space: {$in: spacesIds}}, {$pull: {clusters: clusterId}}, {multi: true})); + return mongo.Cache.update({space: {$in: spacesIds}}, {$pull: {clusters: clusterId}}, {multi: true}); }) - .then(() => mongo.Cache.update(mongo.Igfs.update({space: {$in: spacesIds}}, {$pull: {clusters: clusterId}}, {multi: true}))) + .then(() => mongo.Igfs.update({space: {$in: spacesIds}}, {$pull: {clusters: clusterId}}, {multi: true})) + .then(() => mongo.Cluster.remove(clusterId)) .then(() => res.sendStatus(200)) .catch((err) => { // TODO IGNITE-843 Send error to admin http://git-wip-us.apache.org/repos/asf/ignite/blob/6fc1865e/modules/control-center-web/src/main/js/serve/routes/igfs.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/serve/routes/igfs.js b/modules/control-center-web/src/main/js/serve/routes/igfs.js index 78c49b6..2a0aed4 100644 --- a/modules/control-center-web/src/main/js/serve/routes/igfs.js +++ b/modules/control-center-web/src/main/js/serve/routes/igfs.js @@ -107,10 +107,16 @@ module.exports.factory = function(_, express, mongo) { * Remove IGFS by ._id. */ router.post('/remove', (req, res) => { - mongo.Igfs.remove(req.body, (err) => { - if (mongo.processed(err, res)) - res.sendStatus(200); - }); + const igfsId = req.body; + + mongo.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]}) + .then((spaces) => mongo.Cluster.update({space: {$in: spacesIds}}, {$pull: {igfss: igfsId}}, {multi: true})) + .then(mongo.Igfs.remove(req.body)) + .then(() => res.sendStatus(200)) + .catch((err) => { + // TODO IGNITE-843 Send error to admin + res.status(500).send(err.message); + }); }); /**
