Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rjcorwin/11293947 to your computer and use it in GitHub Desktop.

Select an option

Save rjcorwin/11293947 to your computer and use it in GitHub Desktop.
Based on http://blog.codeborne.com/2011/10/etherpad-lite-migrate-data-from-dirtydb.html but more cautious. Includes a delay so the db has a chance to flush.
var dirty = require("dirty")('./var/dirty.db')
var ueber = require("./db/DB")
ueber.init(function() {
console.log('ueber initialized')
var db = ueber.db
dirty.on("load", function() {
console.log('dirty load complete')
var keys = []
var vals = []
dirty.forEach(function(key, val) {
keys.push(key)
vals.push(val)
})
console.log('finished loading dirty database into memory')
console.log('key has length of ' + keys.length)
function next() {
var key = keys.shift()
var val = vals.shift()
setTimeout(function() {
db.set(key, val)
if (keys.length > 0) {
next()
}
else {
console.log('fin')
exit()
}
}, 50)
}
next()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment