Fix debug log growing uncontrollably

Races between adding new log entries and fetching old ones can cause an
overage of more than one entry.

// FREEBIE
This commit is contained in:
lilia 2016-02-12 18:34:06 -08:00
parent a1743e3cc1
commit 6154dbb8db

View file

@ -29,7 +29,7 @@
},
log: function(str) {
this.add({time: Date.now(), value: str}).save();
if (this.length > MAX_MESSAGES) {
while (this.length > MAX_MESSAGES) {
this.at(0).destroy();
}
},