Delete syncedSettings for deleted libraries on sync error

Not sure how this is possible, but fix it for now. It'll be prevented with a FK
check in 5.0.
This commit is contained in:
Dan Stillman 2015-03-09 19:11:36 -04:00
parent cd358977f3
commit 0aaa0540d9

View File

@ -2107,7 +2107,19 @@ Zotero.Sync.Server = new function () {
var background = Zotero.Sync.Runner.background;
setTimeout(function () {
var libraryID = parseInt(firstChild.getAttribute('libraryID'));
var group = Zotero.Groups.getByLibraryID(libraryID);
try {
var group = Zotero.Groups.getByLibraryID(libraryID);
}
catch (e) {
// Not sure how this is possible, but it's affecting some people
// TODO: Clean up in schema updates with FK check
if (!Zotero.Libraries.exists(libraryID)) {
let sql = "DELETE FROM syncedSettings WHERE libraryID=?";
Zotero.DB.query(sql, libraryID);
return;
}
}
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);