Debugging and temporary fix for relations purging issue

This commit is contained in:
Dan Stillman 2013-11-13 12:08:44 -05:00
parent 2ca0d159b5
commit 6a0c623698

View File

@ -229,21 +229,27 @@ Zotero.Relations = new function () {
var uris = Zotero.DB.columnQuery(sql, [this.deletedItemPredicate, this.deletedItemPredicate]);
if (uris) {
var prefix = Zotero.URI.defaultPrefix;
Zotero.DB.beginTransaction();
for each(var uri in uris) {
// Skip URIs that don't begin with the default prefix,
// since they don't correspond to local items
if (uri.indexOf(prefix) == -1) {
continue;
}
if (uri.indexOf(/\/items\//) != -1 && !Zotero.URI.getURIItem(uri)) {
this.eraseByURI(uri);
}
if (uri.indexOf(/\/collections\//) != -1 && !Zotero.URI.getURICollection(uri)) {
this.eraseByURI(uri);
try {
Zotero.DB.beginTransaction();
for each(var uri in uris) {
// Skip URIs that don't begin with the default prefix,
// since they don't correspond to local items
if (uri.indexOf(prefix) == -1) {
continue;
}
if (uri.indexOf(/\/items\//) != -1 && !Zotero.URI.getURIItem(uri)) {
this.eraseByURI(uri);
}
if (uri.indexOf(/\/collections\//) != -1 && !Zotero.URI.getURICollection(uri)) {
this.eraseByURI(uri);
}
}
Zotero.DB.commitTransaction();
}
catch (e) {
Zotero.debug(e);
Zotero.debug(Zotero.DB.query("SELECT * FROM relations"));
}
Zotero.DB.commitTransaction();
}
}