Browse Source

Fixed issues with removing stations (official and community)

theflametrooper 8 years ago
parent
commit
e319b8aba1
2 changed files with 7 additions and 7 deletions
  1. 4 4
      backend/logic/actions/stations.js
  2. 3 3
      backend/logic/cache/index.js

+ 4 - 4
backend/logic/actions/stations.js

@@ -596,21 +596,21 @@ module.exports = {
 	remove: hooks.ownerRequired((session, stationId, cb) => {
 		async.waterfall([
 			(next) => {
-				db.models.station.remove({ _id: stationId }, next);
+				db.models.station.remove({ _id: stationId }, err => next(err));
 			},
 
 			(next) => {
-				cache.hdel('stations', stationId, next);
+				cache.hdel('stations', stationId, err => next(err));
 			}
 		], (err) => {
 			if (err) {
 				err = utils.getError(err);
 				logger.error("STATIONS_REMOVE", `Removing station "${stationId}" failed. "${err}"`);
-				return cb({'status': 'failure', 'message': err});
+				return cb({ 'status': 'failure', 'message': err });
 			}
 			logger.success("STATIONS_REMOVE", `Removing station "${stationId}" successfully.`);
 			cache.pub('station.remove', stationId);
-			return cb({'status': 'success', 'message': 'Successfully removed.'});
+			return cb({ 'status': 'success', 'message': 'Successfully removed.' });
 		});
 	}),
 

+ 3 - 3
backend/logic/cache/index.js

@@ -102,10 +102,10 @@ const lib = {
 	 * @param {Function} cb - gets called when the value has been deleted from Redis or when it returned an error
 	 */
 	hdel: (table, key, cb) => {
-		if (!key || !table) return typeof cb === 'function' ? cb(null, null) : null;
+		if (!key || !table) return cb(null, null);
 		lib.client.hdel(table, key, (err) => {
-			if (err) return typeof cb === 'function' ? cb(err) : null;
-			if (typeof cb === 'function') cb(null);
+			if (err) return cb(err);
+			else return cb(null);
 		});
 	},