www

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

commit 2eb54166209e591964d09bf09c789697e670e9e5
parent 93703c68d1ac2b915a969eba582672208626cc59
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 29 May 2009 20:47:44 +0000

- Run long tag fixer on first sync error, and then check locally for tags > 255 characters to avoid repeated sync attempts
- Don't run long tag fixer on background sync


Diffstat:
Mchrome/content/zotero/longTagFixer.js | 10+++-------
Mchrome/content/zotero/xpcom/sync.js | 43+++++++++++++++++++++++++++----------------
2 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/chrome/content/zotero/longTagFixer.js b/chrome/content/zotero/longTagFixer.js @@ -1,6 +1,6 @@ var Zotero_Long_Tag_Fixer = new function () { var _oldTag = window.arguments[0]; - var _callback = window.arguments[1]; + var _dataOut = window.arguments[1]; this.init = function () { document.getElementById('zotero-old-tag').value = _oldTag; @@ -103,9 +103,7 @@ var Zotero_Long_Tag_Fixer = new function () { this.cancel = function () { - if (_callback) { - _callback(false); - } + _dataOut.result = false; } @@ -172,9 +170,7 @@ var Zotero_Long_Tag_Fixer = new function () { break; } - if (_callback) { - _callback(true); - } + _dataOut.result = true; } catch (e) { diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js @@ -1480,23 +1480,34 @@ Zotero.Sync.Server = new function () { break; case 'TAG_TOO_LONG': - var tag = xmlhttp.responseXML.firstChild.getElementsByTagName('tag'); - if (tag.length) { - Zotero.DB.rollbackAllTransactions(); - - var tag = tag[0].firstChild.nodeValue; - setTimeout(function () { - var callback = function (success) { - if (success) { - Zotero.Sync.Runner.sync(); - } - }; + if (!Zotero.Sync.Runner.background) { + var tag = xmlhttp.responseXML.firstChild.getElementsByTagName('tag'); + if (tag.length) { + Zotero.DB.rollbackAllTransactions(); - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); - var lastWin = wm.getMostRecentWindow("navigator:browser"); - lastWin.openDialog('chrome://zotero/content/longTagFixer.xul', '', 'chrome,modal,centerscreen', tag, callback); - }, 1); + var tag = tag[0].firstChild.nodeValue; + setTimeout(function () { + var callback = function () { + var sql = "SELECT DISTINCT name FROM itemTags NATURAL JOIN tags WHERE LENGTH(name)>255 LIMIT 1"; + var tag = Zotero.DB.valueQuery(sql); + if (tag) { + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + var lastWin = wm.getMostRecentWindow("navigator:browser"); + var dataOut = { result: null }; + lastWin.openDialog('chrome://zotero/content/longTagFixer.xul', '', 'chrome,modal,centerscreen', tag, dataOut); + if (dataOut.result) { + callback(); + } + } + else { + Zotero.Sync.Runner.sync(); + } + }; + + callback(); + }, 1); + } } break; }