mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-14 17:21:02 +08:00
fixed regressions on tests due to emitToAll and resource caching
This commit is contained in:
@@ -122,7 +122,7 @@ InternalResources.prototype.handle = function(ctx, next) {
|
||||
|
||||
resources = resources || {};
|
||||
|
||||
if(ctx.req.method != 'get') {
|
||||
if(ctx.req.method != 'get' && ctx.server) {
|
||||
// clear cache
|
||||
delete ctx.server.__resourceCache;
|
||||
}
|
||||
|
||||
@@ -221,8 +221,6 @@ Collection.prototype.parseId = function(ctx) {
|
||||
|
||||
Collection.prototype.execListener = function(method, session, query, item, client, fn) {
|
||||
// TODO: find a better way to grab the real id.
|
||||
|
||||
|
||||
var listener = this.settings && this.settings['on' + method]
|
||||
, errors
|
||||
, data = item
|
||||
@@ -239,7 +237,7 @@ Collection.prototype.execListener = function(method, session, query, item, clien
|
||||
} else if(arguments.length <= 2) {
|
||||
event = collection;
|
||||
data = query;
|
||||
session.emitToAll(event, data);
|
||||
if(session.emitToAll) session.emitToAll(event, data);
|
||||
}
|
||||
},
|
||||
error: function(key, val) {
|
||||
@@ -404,7 +402,7 @@ Collection.prototype.remove = function (session, query, client, fn) {
|
||||
collection.execListener('Delete', session, query, result, client, function (err) {
|
||||
if(err) return fn(err);
|
||||
store.remove(query, fn);
|
||||
session.emitToAll(collection.name + ':changed');
|
||||
if(session.emitToAll) session.emitToAll(collection.name + ':changed');
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -488,7 +486,7 @@ Collection.prototype.save = function (session, item, query, client, fn) {
|
||||
item.id = obj.id;
|
||||
fn(null, item);
|
||||
|
||||
session.emitToAll(collection.name + ':changed');
|
||||
if(session.emitToAll) session.emitToAll(collection.name + ':changed');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -507,7 +505,7 @@ Collection.prototype.save = function (session, item, query, client, fn) {
|
||||
return fn(err);
|
||||
}
|
||||
store.insert(item, fn);
|
||||
session.emitToAll(collection.name + ':changed');
|
||||
if(session.emitToAll) session.emitToAll(collection.name + ':changed');
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1,6 @@
|
||||
{"123":{"path":"/foo","type":"Collection","property":"value"},"456":{"path":"/bar","type":"Collection","test":"value"}}
|
||||
{
|
||||
"123": {
|
||||
"path": "/foo",
|
||||
"type": "Bar"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user