Fixes #311, after deleting database, no new database is created

Well that probably would've been mildly frustrating for new users.
This commit is contained in:
Dan Stillman 2006-09-20 02:15:49 +00:00
parent 0f8c3e7669
commit 302f0105bf
2 changed files with 15 additions and 19 deletions

View file

@ -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()){

View file

@ -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'));