From 302f0105bff1c29d75e00837bfb8f8814f075d8f Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 20 Sep 2006 02:15:49 +0000 Subject: [PATCH] Fixes #311, after deleting database, no new database is created Well that probably would've been mildly frustrating for new users. --- .../chromeFiles/content/scholar/xpcom/db.js | 15 +++++++++++++++ .../content/scholar/xpcom/schema.js | 19 ------------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/xpcom/db.js b/chrome/chromeFiles/content/scholar/xpcom/db.js index 6a92139916..e6e413e1ba 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/db.js +++ b/chrome/chromeFiles/content/scholar/xpcom/db.js @@ -394,6 +394,21 @@ Scholar.DB = new function(){ var file = Scholar.getScholarDatabase(); var backupFile = Scholar.getScholarDatabase('bak'); + if (SCHOLAR_CONFIG['DB_REBUILD']){ + if (confirm('Erase all user data and recreate database from schema?')){ + // Delete existing Zotero database + if (file.exists()){ + file.remove(null); + } + + // Delete existing storage folder + var dir = Scholar.getStorageDirectory(); + if (dir.exists()){ + dir.remove(true); + } + } + } + // DEBUG: Temporary check // Test the backup file (to make sure the backup mechanism is working) if (backupFile.exists()){ diff --git a/chrome/chromeFiles/content/scholar/xpcom/schema.js b/chrome/chromeFiles/content/scholar/xpcom/schema.js index ad30c26bdf..acb32d158b 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/schema.js +++ b/chrome/chromeFiles/content/scholar/xpcom/schema.js @@ -11,13 +11,6 @@ Scholar.Schema = new function(){ * Checks if the DB schema exists and is up-to-date, updating if necessary */ function updateSchema(){ - if (SCHOLAR_CONFIG['DB_REBUILD']){ - if (confirm('Erase all user data and recreate database from schema?')){ - _initializeSchema(); - return; - } - } - var dbVersion = _getDBVersion('user'); // 'schema' check is for old (<= 1.0b1) schema system @@ -277,18 +270,6 @@ Scholar.Schema = new function(){ * Create new DB schema */ function _initializeSchema(){ - // Delete existing Zotero database - var file = Scholar.getScholarDatabase(); - if (file.exists()){ - file.remove(null); - } - - // Delete existing storage folder - var dir = Scholar.getStorageDirectory(); - if (dir.exists()){ - dir.remove(true); - } - Scholar.DB.beginTransaction(); try { Scholar.DB.query(_getSchemaSQL('user'));