fixed setAutocompactionInterval interval arg

if interval is undefined, then it's bigger than 5000

Test case in Chrome console:
```
> var interval
undefined
> (interval < 5000)
false
```
pull/2/head
Anatoly Pashin 11 years ago
parent 7e1616fe03
commit 790562c45f
  1. 8
      lib/persistence.js

@ -155,14 +155,16 @@ Persistence.prototype.compactDatafile = function () {
* @param {Number} interval in milliseconds, with an enforced minimum of 5 seconds * @param {Number} interval in milliseconds, with an enforced minimum of 5 seconds
*/ */
Persistence.prototype.setAutocompactionInterval = function (interval) { Persistence.prototype.setAutocompactionInterval = function (interval) {
var self = this; var self = this
, minInterval = 5000
, realInterval = Math.max(interval||0, minInterval)
;
if (interval < 5000) { interval = 5000; }
this.stopAutocompaction(); this.stopAutocompaction();
this.autocompactionIntervalId = setInterval(function () { this.autocompactionIntervalId = setInterval(function () {
self.compactDatafile(); self.compactDatafile();
}, interval); }, realInterval);
}; };

Loading…
Cancel
Save