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:
parent
0f8c3e7669
commit
302f0105bf
2 changed files with 15 additions and 19 deletions
|
@ -394,6 +394,21 @@ Scholar.DB = new function(){
|
||||||
var file = Scholar.getScholarDatabase();
|
var file = Scholar.getScholarDatabase();
|
||||||
var backupFile = Scholar.getScholarDatabase('bak');
|
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
|
// DEBUG: Temporary check
|
||||||
// Test the backup file (to make sure the backup mechanism is working)
|
// Test the backup file (to make sure the backup mechanism is working)
|
||||||
if (backupFile.exists()){
|
if (backupFile.exists()){
|
||||||
|
|
|
@ -11,13 +11,6 @@ Scholar.Schema = new function(){
|
||||||
* Checks if the DB schema exists and is up-to-date, updating if necessary
|
* Checks if the DB schema exists and is up-to-date, updating if necessary
|
||||||
*/
|
*/
|
||||||
function updateSchema(){
|
function updateSchema(){
|
||||||
if (SCHOLAR_CONFIG['DB_REBUILD']){
|
|
||||||
if (confirm('Erase all user data and recreate database from schema?')){
|
|
||||||
_initializeSchema();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var dbVersion = _getDBVersion('user');
|
var dbVersion = _getDBVersion('user');
|
||||||
|
|
||||||
// 'schema' check is for old (<= 1.0b1) schema system
|
// 'schema' check is for old (<= 1.0b1) schema system
|
||||||
|
@ -277,18 +270,6 @@ Scholar.Schema = new function(){
|
||||||
* Create new DB schema
|
* Create new DB schema
|
||||||
*/
|
*/
|
||||||
function _initializeSchema(){
|
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();
|
Scholar.DB.beginTransaction();
|
||||||
try {
|
try {
|
||||||
Scholar.DB.query(_getSchemaSQL('user'));
|
Scholar.DB.query(_getSchemaSQL('user'));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue