Add creator fix to integrity check, and run at startup if necessary
This commit is contained in:
parent
1cb49cc5d3
commit
7d3311679e
2 changed files with 28 additions and 6 deletions
|
@ -31,10 +31,12 @@ Zotero.Creators = new function() {
|
||||||
var _cache = {};
|
var _cache = {};
|
||||||
|
|
||||||
this.init = Zotero.Promise.coroutine(function* () {
|
this.init = Zotero.Promise.coroutine(function* () {
|
||||||
|
var repaired = false;
|
||||||
var sql = "SELECT * FROM creators";
|
var sql = "SELECT * FROM creators";
|
||||||
var rows = yield Zotero.DB.queryAsync(sql);
|
var rows = yield Zotero.DB.queryAsync(sql);
|
||||||
for (let i = 0; i < rows.length; i++) {
|
for (let i = 0; i < rows.length; i++) {
|
||||||
let row = rows[i];
|
let row = rows[i];
|
||||||
|
try {
|
||||||
_cache[row.creatorID] = this.cleanData({
|
_cache[row.creatorID] = this.cleanData({
|
||||||
// Avoid "DB column 'name' not found" warnings from the DB row Proxy
|
// Avoid "DB column 'name' not found" warnings from the DB row Proxy
|
||||||
firstName: row.firstName,
|
firstName: row.firstName,
|
||||||
|
@ -42,6 +44,21 @@ Zotero.Creators = new function() {
|
||||||
fieldMode: row.fieldMode
|
fieldMode: row.fieldMode
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
|
// Automatically fix DB errors and try again
|
||||||
|
if (!repaired) {
|
||||||
|
Zotero.logError(e);
|
||||||
|
Zotero.logError("Trying integrity check to fix creator error");
|
||||||
|
yield Zotero.Schema.integrityCheck(true);
|
||||||
|
repaired = true;
|
||||||
|
rows = yield Zotero.DB.queryAsync(sql);
|
||||||
|
i = -1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1334,6 +1334,11 @@ Zotero.Schema = new function(){
|
||||||
[
|
[
|
||||||
"SELECT COUNT(*) > 0 FROM itemAttachments WHERE linkMode NOT IN (0,1,2,3)",
|
"SELECT COUNT(*) > 0 FROM itemAttachments WHERE linkMode NOT IN (0,1,2,3)",
|
||||||
"UPDATE itemAttachments SET linkMode=1 WHERE linkMode NOT IN (0,1,2,3)"
|
"UPDATE itemAttachments SET linkMode=1 WHERE linkMode NOT IN (0,1,2,3)"
|
||||||
|
],
|
||||||
|
// Creators with first name can't be fieldMode 1
|
||||||
|
[
|
||||||
|
"SELECT COUNT(*) > 0 FROM creators WHERE fieldMode = 1 AND firstName != ''",
|
||||||
|
"UPDATE creators SET fieldMode = 0 WHERE fieldMode = 1 AND firstName != ''"
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue