From 789dbb1e734885bd7cf5ad25f0d2f47765a13657 Mon Sep 17 00:00:00 2001 From: pep Date: Tue, 21 Jul 2020 20:48:09 +0000 Subject: attempt at merge --- bucky/search/bdb.js | 55 ----------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 bucky/search/bdb.js (limited to 'bucky/search/bdb.js') diff --git a/bucky/search/bdb.js b/bucky/search/bdb.js deleted file mode 100644 index 6f1fd98..0000000 --- a/bucky/search/bdb.js +++ /dev/null @@ -1,55 +0,0 @@ -var bdb_lib = require('berkeleydb') -var dbenv = new bdb_lib.DbEnv(); -var bdb_status = dbenv.open('./search/db/env') -if (bdb_status) { - console.log('open dbenv failed:', bdb_status) - process.exit() -} - -function db(fn){ - var db - fn = "./" + fn + ".db" - - function exitHandler(options, err) { - if (db) db.close() - // if (options.cleanup) console.log('clean'); - if (err) console.log(err.stack); - if (options.exit) process.exit(); - } - - // do something when app is closing - process.on('exit', exitHandler.bind(null, {cleanup: true})); - - // catches ctrl+c event - process.on('SIGINT', exitHandler.bind(null, {exit: true})); - - // catches "kill pid" (for example: nodemon restart) - process.on('SIGUSR1', exitHandler.bind(null, {exit: true})); - process.on('SIGUSR2', exitHandler.bind(null, {exit: true})); - - //catches uncaught exceptions - process.on('uncaughtException', exitHandler.bind(null, {exit:true})); - - function open(fn){ - if (db) db.close() - var _db = new bdb_lib.Db(dbenv); - var bdb_status = _db.open(fn) - if (bdb_status) { - console.log('openĀ ' + fn + ' failed:', bdb_status) - process.exit() - } - db = _db - } - - open(fn) - - return { - put: function(term, serialized){ - db.put(term, serialized) - }, - get: function(term){ - return db.get(term) - }, - } -} -module.exports = db -- cgit v1.2.3-70-g09d2