Commits

Mathias Panzenböck  committed 3dbfb95

nodejitsu supports SQLite again!

  • Participants
  • Parent commits 60ae40b

Comments (0)

Files changed (3)

 !images/logo_bright.png
 !images/spinner.png
 !images/mask.svg
-!db/magnatune.json.gz
 **/.directory
 var mime    = require('express/node_modules/mime');
 var async   = require('async');
 var unorm   = require('unorm');
+var sqlite3 = require('sqlite3');
+var cron    = require('cron');
 
 console._time = console.time;
 console.time = function (msg) {
 
 if (!fs.exists) fs.exists = path.exists;
 
-var sqlite3;
-
-try {
-	sqlite3 = require('node-sqlite-purejs');
-
-	if (!sqlite3.prototype.close) sqlite3.prototype.close = function (cb) {
-		try {
-			this.db.close();
-		}
-		catch (e) {
-			return cb(e);
-		}
-		return cb(null);
-	};
-}
-catch (e) {
-	sqlite3 = null;
-}
-sqlite3 = null;
-
-var cron = sqlite3 ? require('cron') : null;
-
 function uniq (xs) {
 	var ys = [];
 	var visited = {};
 				fs.writeFile('db/changed.txt', changed+" "+new Date().toUTCString()+"\n", "utf8", function (err) {
 					if (err) return end(err);
 
-					sqlite3.open(DB_FILE, {}, function (err, db) {
+					var db = new sqlite3.Database(DB_FILE, function (err) {
 						if (err) return end(err);
 
-						new Collection().load(db, function (err, coll) {
+						new Collection().loadSQLite(db, function (err, coll) {
 							if (err) return end(err);
 
 							db.close(function (err) {
 
 			// load artists
 			function (done) {
-				db.exec(
+				db.all(
 					'select artist, description, homepage, city, state, country, bio, bandphoto '+
 					'from artists order by artist', function (err, artists) {
 					if (err) return done(err);
 
 			// load albums
 			function (done) {
-				db.exec(
+				db.all(
 					'select artist, albumname, also, description, sku, launchdate, upc, itunes '+
 					'from albums order by albumname', function (err, albums) {
 					if (err) return done(err);
 
 			// load genres
 			function (done) {
-				db.exec(
+				db.all(
 					'select genre, albumname from genres order by genre, albumname', function (err, albums_to_genres) {
 					if (err) return done(err);
 
 
 			// load songs
 			function (done) {
-				db.exec(
+				db.all(
 					'select albumname, number, duration, mp3, desc from songs order by albumname, number', function (err, songs) {
 					if (err) return done(err);
 
 	updateDB(function (err) {
 		if (err) throw err;
 		if (!collection) {
-			sqlite3.open(DB_FILE, {}, function (err, db) {
+			var db = new sqlite3.Database(DB_FILE, function (err) {
 				if (err) throw err;
 				new Collection().loadSQLite(db, function (err, coll) {
 					if (err) throw err;

File package.json

 {
   "name": "GreattunePlayer",
   "subdomain": "greattuneplayer",
-  "version": "0.1.0-190",
+  "version": "0.1.0-191",
   "author": "Mathias Panzenböck",
   "description": "This is a HTML5 audio player based on the music from Magnatune.com",
   "bin": {
     "express": "2.x",
     "async": ">= 0.x",
     "cron": ">= 0.x",
-    "unorm": ">= 1.1.2"
+    "unorm": ">= 1.1.2",
+    "sqlite3": "~2.1.17"
   },
   "license": "GPLv2",
   "engines": {