[fix] only reverse keys for "get" action to be safe.

This commit is contained in:
Christopher Jeffrey 2014-02-12 12:31:55 -06:00
parent 999c6fbc6e
commit 8105c761ad

View file

@ -507,7 +507,12 @@ Provider.prototype._execute = function (action, syncLength /* [arguments] */) {
destructive = ['set', 'clear', 'merge', 'reset'].indexOf(action) !== -1, destructive = ['set', 'clear', 'merge', 'reset'].indexOf(action) !== -1,
self = this, self = this,
response, response,
mergeObjs = []; mergeObjs = [],
keys = Object.keys(this.stores);
if (action === 'get') {
keys = keys.reverse();
}
function runAction (name, next) { function runAction (name, next) {
var store = self.stores[name]; var store = self.stores[name];
@ -522,13 +527,12 @@ Provider.prototype._execute = function (action, syncLength /* [arguments] */) {
} }
if (callback) { if (callback) {
return async.forEach(Object.keys(this.stores).reverse(), runAction, function (err) { return async.forEach(keys, runAction, function (err) {
return err ? callback(err) : callback(); return err ? callback(err) : callback();
}); });
} }
keys.forEach(function (name) {
Object.keys(this.stores).reverse().forEach(function (name) {
if (typeof response === 'undefined') { if (typeof response === 'undefined') {
var store = self.stores[name]; var store = self.stores[name];