Use coroutine() for Zotero.Schema::_updateSchema()
This commit is contained in:
parent
56d9372146
commit
7e30afb2a5
1 changed files with 16 additions and 18 deletions
|
@ -1418,26 +1418,24 @@ Zotero.Schema = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function _updateSchema(schema){
|
/**
|
||||||
return Zotero.Promise.all([Zotero.Schema.getDBVersion(schema), _getSchemaSQLVersion(schema)])
|
* Requires a transaction
|
||||||
.spread(function (dbVersion, schemaVersion) {
|
*/
|
||||||
|
var _updateSchema = Zotero.Promise.coroutine(function* (schema) {
|
||||||
|
var [dbVersion, schemaVersion] = yield Zotero.Promise.all(
|
||||||
|
[Zotero.Schema.getDBVersion(schema), _getSchemaSQLVersion(schema)]
|
||||||
|
);
|
||||||
if (dbVersion == schemaVersion) {
|
if (dbVersion == schemaVersion) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (dbVersion < schemaVersion) {
|
if (dbVersion > schemaVersion) {
|
||||||
return _getSchemaSQL(schema)
|
|
||||||
.then(function (sql) {
|
|
||||||
return Zotero.DB.executeSQLFile(sql);
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
return _updateDBVersion(schema, schemaVersion);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error("Zotero '" + schema + "' DB version (" + dbVersion
|
throw new Error("Zotero '" + schema + "' DB version (" + dbVersion
|
||||||
+ ") is newer than SQL file (" + schemaVersion + ")");
|
+ ") is newer than SQL file (" + schemaVersion + ")");
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
let sql = yield _getSchemaSQL(schema);
|
||||||
|
yield Zotero.DB.executeSQLFile(sql);
|
||||||
|
return _updateDBVersion(schema, schemaVersion);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
var _updateCompatibility = Zotero.Promise.coroutine(function* (version) {
|
var _updateCompatibility = Zotero.Promise.coroutine(function* (version) {
|
||||||
|
|
Loading…
Reference in a new issue