From 5b60a48c7fe1ea4ee899b93622aff9a76393cd19 Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Wed, 31 Aug 2016 21:33:56 -0700 Subject: [PATCH] Fix double save when reloading partition map --- src/server.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/server.js b/src/server.js index 4821e4a1..5110fc47 100644 --- a/src/server.js +++ b/src/server.js @@ -220,14 +220,20 @@ Server.prototype.getChannel = function (name) { return c; }; -Server.prototype.unloadChannel = function (chan) { +Server.prototype.unloadChannel = function (chan, options) { if (chan.dead) { return; } - chan.saveState().catch(error => { - Logger.errlog.log(`Failed to save /r/${chan.name} for unload: ${error.stack}`); - }); + if (!options) { + options = {}; + } + + if (!options.skipSave) { + chan.saveState().catch(error => { + Logger.errlog.log(`Failed to save /r/${chan.name} for unload: ${error.stack}`); + }); + } chan.logger.log("[init] Channel shutting down"); chan.logger.close(); @@ -359,7 +365,7 @@ Server.prototype.reloadPartitionMap = function () { } catch (error) { } }); - this.unloadChannel(channel); + this.unloadChannel(channel, { skipSave: true }); }).catch(error => { Logger.errlog.log(`Failed to unload /r/${channel.name} for ` + `partition map flip: ${error.stack}`);