From 928d02df5ce0ba2f57a5de418e39e941183d7e57 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 17 Mar 2016 21:53:30 -0500 Subject: [PATCH] Avoid migrating WebSQL if it didn't exist #167 --- storage-websql.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/storage-websql.js b/storage-websql.js index 24765ce5..8531b304 100644 --- a/storage-websql.js +++ b/storage-websql.js @@ -31,6 +31,10 @@ var webSqlStorage = { getStyles: function(callback) { webSqlStorage.getDatabase(function(db) { + if (!db) { + callback([]); + return; + } db.readTransaction(function (t) { var where = ""; var params = []; @@ -92,7 +96,12 @@ var webSqlStorage = { error(); throw ex; } - if (stylishDb.version == "1.0" || stylishDb.version == "") { + if (stylishDb.version == "") { + // It didn't already exist, we have nothing to migrate. + ready(null); + return; + } + if (stylishDb.version == "1.0") { webSqlStorage.dbV11(stylishDb, error, ready); } else if (stylishDb.version == "1.1") { webSqlStorage.dbV12(stylishDb, error, ready);