Fix loading of compressed global schema from DB on downgrade
This commit is contained in:
parent
f5d544bc15
commit
8fe33dc91c
2 changed files with 11 additions and 6 deletions
|
@ -580,7 +580,9 @@ Zotero.DBConnection.prototype.queryAsync = Zotero.Promise.coroutine(function* (s
|
||||||
try {
|
try {
|
||||||
let onRow = null;
|
let onRow = null;
|
||||||
let conn = this._getConnection(options) || (yield this._getConnectionAsync(options));
|
let conn = this._getConnection(options) || (yield this._getConnectionAsync(options));
|
||||||
[sql, params] = this.parseQueryAndParams(sql, params);
|
if (!options || !options.noParseParams) {
|
||||||
|
[sql, params] = this.parseQueryAndParams(sql, params);
|
||||||
|
}
|
||||||
if (Zotero.Debug.enabled) {
|
if (Zotero.Debug.enabled) {
|
||||||
this.logQuery(sql, params, options);
|
this.logQuery(sql, params, options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,13 +322,12 @@ Zotero.Schema = new function(){
|
||||||
* Doesn't include the .itemTypes property, which was already applied to the mapping tables
|
* Doesn't include the .itemTypes property, which was already applied to the mapping tables
|
||||||
*/
|
*/
|
||||||
async function _readGlobalSchemaFromDB() {
|
async function _readGlobalSchemaFromDB() {
|
||||||
var pako = {};
|
|
||||||
Services.scriptloader.loadSubScript("resource://zotero/pako.js", pako);
|
|
||||||
var data = await Zotero.DB.valueQueryAsync(
|
var data = await Zotero.DB.valueQueryAsync(
|
||||||
"SELECT value FROM settings WHERE setting='globalSchema' AND key='data'"
|
"SELECT value FROM settings WHERE setting='globalSchema' AND key='data'"
|
||||||
);
|
);
|
||||||
if (data) {
|
if (data) {
|
||||||
try {
|
try {
|
||||||
|
let pako = require('pako');
|
||||||
return JSON.parse(pako.inflate(data, { to: 'string' }));
|
return JSON.parse(pako.inflate(data, { to: 'string' }));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
@ -360,7 +359,8 @@ Zotero.Schema = new function(){
|
||||||
|
|
||||||
var dbVersion = await Zotero.Schema.getDBVersion('globalSchema') || null;
|
var dbVersion = await Zotero.Schema.getDBVersion('globalSchema') || null;
|
||||||
if (dbVersion > version) {
|
if (dbVersion > version) {
|
||||||
Zotero.debug(`Database has newer global schema (${dbVersion} > ${version}) -- skipping update`);
|
Zotero.debug(`Database has newer global schema (${dbVersion} > ${version}) `
|
||||||
|
+ `-- skipping update and using schema from DB`);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (dbVersion == version) {
|
else if (dbVersion == version) {
|
||||||
|
@ -524,9 +524,12 @@ Zotero.Schema = new function(){
|
||||||
// Don't include types and fields, which are already in the mapping tables
|
// Don't include types and fields, which are already in the mapping tables
|
||||||
delete dbData.itemTypes;
|
delete dbData.itemTypes;
|
||||||
await Zotero.DB.queryAsync(
|
await Zotero.DB.queryAsync(
|
||||||
"REPLACE INTO settings VALUES ('globalSchema', 'data', ?)",
|
"REPLACE INTO settings VALUES ('globalSchema', 'data', :data)",
|
||||||
pako.deflate(JSON.stringify(dbData), { to: 'string' }),
|
{ data: pako.deflate(JSON.stringify(dbData)) },
|
||||||
{
|
{
|
||||||
|
// Hack to pass named parameter to Sqlite.jsm, which in Fx60 treats an object passed
|
||||||
|
// as the the first parameter in a parameter array as an object of named parameters
|
||||||
|
noParseParams: true,
|
||||||
debugParams: false
|
debugParams: false
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue