www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 22e0ba3a225f0fd78cc8914697b519fdc4d4f9f8
parent cf010d77484954f4907dad6af1af9986dc534660
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 22 May 2015 15:50:27 -0400

Fix hangs related to data object purging

Diffstat:
Mchrome/content/zotero/xpcom/data/group.js | 4++--
Mchrome/content/zotero/xpcom/data/tags.js | 100++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mchrome/content/zotero/xpcom/zotero.js | 4++--
3 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/chrome/content/zotero/xpcom/data/group.js b/chrome/content/zotero/xpcom/data/group.js @@ -333,11 +333,11 @@ Zotero.Group.prototype.erase = Zotero.Promise.coroutine(function* () { sql = "DELETE FROM libraries WHERE libraryID=?"; yield Zotero.DB.queryAsync(sql, this.libraryID) - yield Zotero.purgeDataObjects(); - Zotero.Groups.unregister(this.id); Zotero.Notifier.trigger('delete', 'group', this.id, notifierData); }.bind(this)); + + yield Zotero.purgeDataObjects(); }); diff --git a/chrome/content/zotero/xpcom/data/tags.js b/chrome/content/zotero/xpcom/data/tags.js @@ -370,61 +370,61 @@ Zotero.Tags = new function() { tagIDs = Zotero.flattenArguments(tagIDs); } - yield Zotero.DB.executeTransaction(function* () { - yield Zotero.Tags.load(libraryID); - - // Use given tags, as long as they're orphaned - if (tagIDs) { - let sql = "CREATE TEMPORARY TABLE tagDelete (tagID INT PRIMARY KEY)"; - yield Zotero.DB.queryAsync(sql); - for (let i=0; i<tagIDs.length; i++) { - yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO tagDelete VALUES (?)", tagIDs[i]); - } - sql = "SELECT * FROM tagDelete WHERE tagID NOT IN (SELECT tagID FROM itemTags)"; - var toDelete = yield Zotero.DB.columnQueryAsync(sql); - } - // Look for orphaned tags - else { - var sql = "CREATE TEMPORARY TABLE tagDelete AS " - + "SELECT tagID FROM tags WHERE tagID " - + "NOT IN (SELECT tagID FROM itemTags)"; - yield Zotero.DB.queryAsync(sql); - - sql = "CREATE INDEX tagDelete_tagID ON tagDelete(tagID)"; - yield Zotero.DB.queryAsync(sql); - - sql = "SELECT * FROM tagDelete"; - var toDelete = yield Zotero.DB.columnQueryAsync(sql); - - if (!toDelete) { - sql = "DROP TABLE tagDelete"; - return Zotero.DB.queryAsync(sql); - } - } - - notifierData = {}; - for (let i=0; i<toDelete.length; i++) { - let id = toDelete[i]; - if (_tagNamesByID[id]) { - notifierData[id] = { - old: { - libraryID: libraryID, - tag: _tagNamesByID[id] - } - }; - } + Zotero.DB.requireTransaction(); + + yield Zotero.Tags.load(libraryID); + + // Use given tags, as long as they're orphaned + if (tagIDs) { + let sql = "CREATE TEMPORARY TABLE tagDelete (tagID INT PRIMARY KEY)"; + yield Zotero.DB.queryAsync(sql); + for (let i=0; i<tagIDs.length; i++) { + yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO tagDelete VALUES (?)", tagIDs[i]); } - - _unload(libraryID, toDelete); - - sql = "DELETE FROM tags WHERE tagID IN (SELECT tagID FROM tagDelete);"; + sql = "SELECT * FROM tagDelete WHERE tagID NOT IN (SELECT tagID FROM itemTags)"; + var toDelete = yield Zotero.DB.columnQueryAsync(sql); + } + // Look for orphaned tags + else { + var sql = "CREATE TEMPORARY TABLE tagDelete AS " + + "SELECT tagID FROM tags WHERE tagID " + + "NOT IN (SELECT tagID FROM itemTags)"; yield Zotero.DB.queryAsync(sql); - sql = "DROP TABLE tagDelete"; + sql = "CREATE INDEX tagDelete_tagID ON tagDelete(tagID)"; yield Zotero.DB.queryAsync(sql); - Zotero.Notifier.trigger('delete', 'tag', toDelete, notifierData); - }.bind(this)); + sql = "SELECT * FROM tagDelete"; + var toDelete = yield Zotero.DB.columnQueryAsync(sql); + + if (!toDelete) { + sql = "DROP TABLE tagDelete"; + return Zotero.DB.queryAsync(sql); + } + } + + notifierData = {}; + for (let i=0; i<toDelete.length; i++) { + let id = toDelete[i]; + if (_tagNamesByID[id]) { + notifierData[id] = { + old: { + libraryID: libraryID, + tag: _tagNamesByID[id] + } + }; + } + } + + _unload(libraryID, toDelete); + + sql = "DELETE FROM tags WHERE tagID IN (SELECT tagID FROM tagDelete);"; + yield Zotero.DB.queryAsync(sql); + + sql = "DROP TABLE tagDelete"; + yield Zotero.DB.queryAsync(sql); + + Zotero.Notifier.trigger('delete', 'tag', toDelete, notifierData); Zotero.Prefs.set('purge.tags', false); }); diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js @@ -2061,11 +2061,11 @@ Components.utils.import("resource://gre/modules/osfile.jsm"); // TEMP: Disabled until we have async DB (and maybe SQLite FTS) //Zotero.Fulltext.purgeUnusedWords(); yield Zotero.DB.executeTransaction(function* () { - yield Zotero.Items.purge(); + return Zotero.Items.purge(); }); // DEBUG: this might not need to be permanent yield Zotero.DB.executeTransaction(function* () { - yield Zotero.Relations.purge(); + return Zotero.Relations.purge(); }); });