Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit aa6a058

Browse files
author
Tom Bell
committed
Merge pull request #975 from brentc/issue-974
Disable auto-saves until the data has been loaded
2 parents 372ced6 + 2b20f1d commit aa6a058

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/scripts/redis-brain.coffee

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,21 @@ module.exports = (robot) ->
3434
if err
3535
throw err
3636
else if reply
37+
robot.logger.info "Brain data retrieved from redis-brain storage"
3738
robot.brain.mergeData JSON.parse(reply.toString())
3839
else
3940
robot.logger.info "Initializing new redis-brain storage"
4041
robot.brain.mergeData {}
4142

43+
robot.logger.info "Enabling brain auto-saving"
44+
robot.brain.setAutoSave true
45+
46+
# Prevent autosaves until connect has occured
47+
robot.logger.info "Disabling brain auto-saving"
48+
robot.brain.setAutoSave false
49+
4250
robot.brain.on 'save', (data = {}) ->
51+
robot.logger.debug "Saving brain data"
4352
client.set 'hubot:storage', JSON.stringify data
4453

4554
robot.brain.on 'close', ->

0 commit comments

Comments
 (0)