From 318e5b2dd6e992c09b36be910d7c4ed43f97bb71 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 14 Aug 2013 10:51:05 -0400 Subject: [PATCH 1/8] Enable debug line for file sync --- chrome/content/zotero/xpcom/storage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index 8b6bdbbc9..f393644fc 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -949,7 +949,7 @@ Zotero.Sync.Storage = new function () { let item = items.shift(); let row = attachmentData[item.id]; let lk = item.libraryKey; - //Zotero.debug("Checking attachment file for item " + lk); + Zotero.debug("Checking attachment file for item " + lk); let nsIFile = item.getFile(row, true); if (!nsIFile) { From dde09c54a201a4298815135cdd0eb76903992234 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 15 Aug 2013 13:43:14 -0400 Subject: [PATCH 2/8] Fix handling of errors when saving items to data store asynchronously --- chrome/content/zotero/xpcom/translation/translate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index 1cc1df643..7b0f527fc 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -1304,8 +1304,6 @@ Zotero.Translate.Base.prototype = { if(!this._waitingForRPC) this._detectTranslatorsCollected(); } } else { - this._currentState = null; - // unset return value is equivalent to true if(returnValue === undefined) returnValue = true; @@ -1328,6 +1326,8 @@ Zotero.Translate.Base.prototype = { this._runHandler("error", error); } + this._currentState = null; + // call handlers this._runHandler("itemsDone", returnValue); if(returnValue) { From 14192059ce094df311babf893c97cda3c7862bbd Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 15 Aug 2013 13:59:43 -0400 Subject: [PATCH 3/8] Fix innocuous "itemProgress is not defined" error --- chrome/content/zotero/browser.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index 8bb5d02ce..e9abfafa4 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -58,6 +58,7 @@ var Zotero_Browser = new function() { this.isScraping = false; var _browserData = new Object(); + var _attachmentsMap = new WeakMap(); var _blacklist = [ "googlesyndication.com", @@ -533,6 +534,7 @@ var Zotero_Browser = new function() { translate.clearHandlers("done"); translate.clearHandlers("itemDone"); + translate.clearHandlers("attachmentProgress"); translate.setHandler("done", function(obj, returnValue) { if(!returnValue) { @@ -550,8 +552,6 @@ var Zotero_Browser = new function() { Zotero_Browser.isScraping = false; }); - var attachmentsMap = new WeakMap(); - translate.setHandler("itemDone", function(obj, dbItem, item) { Zotero_Browser.progress.show(); var itemProgress = new Zotero_Browser.progress.ItemProgress(Zotero.ItemTypes.getImageSrc(item.itemType), @@ -559,7 +559,7 @@ var Zotero_Browser = new function() { itemProgress.setProgress(100); for(var i=0; i Date: Thu, 15 Aug 2013 14:27:31 -0400 Subject: [PATCH 4/8] Rename Zotero.ID.getKey() to Zotero.Utilites.generateObjectKey() (To make it accessible to the connector) --- chrome/content/zotero/xpcom/data/collection.js | 2 +- chrome/content/zotero/xpcom/data/creator.js | 2 +- chrome/content/zotero/xpcom/data/item.js | 2 +- chrome/content/zotero/xpcom/data/tag.js | 2 +- chrome/content/zotero/xpcom/id.js | 7 ------- chrome/content/zotero/xpcom/schema.js | 12 ++++++------ chrome/content/zotero/xpcom/utilities.js | 9 +++++++++ 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js index 70284f3ca..8f501aa48 100644 --- a/chrome/content/zotero/xpcom/data/collection.js +++ b/chrome/content/zotero/xpcom/data/collection.js @@ -1497,5 +1497,5 @@ Zotero.Collection.prototype._refreshChildCollections = function () { Zotero.Collection.prototype._generateKey = function () { - return Zotero.ID.getKey(); + return Zotero.Utilites.generateObjectKey(); } diff --git a/chrome/content/zotero/xpcom/data/creator.js b/chrome/content/zotero/xpcom/data/creator.js index c9051d8b8..738e98d7c 100644 --- a/chrome/content/zotero/xpcom/data/creator.js +++ b/chrome/content/zotero/xpcom/data/creator.js @@ -552,7 +552,7 @@ Zotero.Creator.prototype._checkValue = function (field, value) { Zotero.Creator.prototype._generateKey = function () { - return Zotero.ID.getKey(); + return Zotero.Utilites.generateObjectKey(); } diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index b04c12bcb..fecb0d847 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -5193,7 +5193,7 @@ Zotero.Item.prototype._clearFieldChange = function (field) { Zotero.Item.prototype._generateKey = function () { - return Zotero.ID.getKey(); + return Zotero.Utilites.generateObjectKey(); } diff --git a/chrome/content/zotero/xpcom/data/tag.js b/chrome/content/zotero/xpcom/data/tag.js index 810a142f3..5aaaaf099 100644 --- a/chrome/content/zotero/xpcom/data/tag.js +++ b/chrome/content/zotero/xpcom/data/tag.js @@ -773,6 +773,6 @@ Zotero.Tag.prototype._prepFieldChange = function (field) { Zotero.Tag.prototype._generateKey = function () { - return Zotero.ID.getKey(); + return Zotero.Utilites.generateObjectKey(); } diff --git a/chrome/content/zotero/xpcom/id.js b/chrome/content/zotero/xpcom/id.js index c444dc2a7..120f9527c 100644 --- a/chrome/content/zotero/xpcom/id.js +++ b/chrome/content/zotero/xpcom/id.js @@ -86,13 +86,6 @@ Zotero.ID_Tracker = function () { } - function getKey() { - // TODO: add 'L' and 'Y' after 3.0.11 cut-off - var baseString = "23456789ABCDEFGHIJKMNPQRSTUVWXZ"; - return Zotero.randomString(8, baseString); - } - - this.isValidKey = function (value) { var re = /^[23456789ABCDEFGHIJKLMNPQRSTUVWXYZ]{8}$/ return re.test(value); diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index 33c81657c..e991c89d7 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -2335,7 +2335,7 @@ Zotero.Schema = new function(){ for (var j=0, len=data.length; j Date: Thu, 15 Aug 2013 14:27:31 -0400 Subject: [PATCH 5/8] Rename Zotero.ID.getKey() to Zotero.Utilites.generateObjectKey() (To make it accessible to the connector) --- chrome/content/zotero/xpcom/id.js | 1 - 1 file changed, 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/id.js b/chrome/content/zotero/xpcom/id.js index 120f9527c..4d68d7911 100644 --- a/chrome/content/zotero/xpcom/id.js +++ b/chrome/content/zotero/xpcom/id.js @@ -25,7 +25,6 @@ Zotero.ID_Tracker = function () { this.get = get; - this.getKey = getKey; this.getBigInt = getBigInt; this.skip = skip; this.getTableName = getTableName; From 71e7fde327713dc9becea13e4f7f78af818bd26c Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 15 Aug 2013 13:42:08 -0400 Subject: [PATCH 6/8] Return multiple items from Zotero.Utilities.itemToServerJSON() --- chrome/content/zotero/xpcom/utilities.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index 9362be1b4..b77b2b0e8 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -1255,10 +1255,11 @@ Zotero.Utilities = { }, /** - * Converts an item from toArray() format to content=json format used by the server + * Converts an item from toArray() format to an array of items in + * the content=json format used by the server */ "itemToServerJSON":function(item) { - var newItem = {}; + var newItem = {}, newItems = [newItem]; var typeID = Zotero.ItemTypes.getID(item.itemType); if(!typeID) { @@ -1337,7 +1338,6 @@ Zotero.Utilities = { } else if(field === "notes") { // normalize notes var n = val.length; - var newNotes = newItem.notes = new Array(n); for(var j=0; j Date: Thu, 15 Aug 2013 15:35:58 -0400 Subject: [PATCH 7/8] Use API v2 in connector, part 1 --- .../zotero/xpcom/connector/translate_item.js | 109 ++++++++---------- .../zotero/xpcom/translation/translate.js | 4 +- chrome/content/zotero/xpcom/utilities.js | 11 +- 3 files changed, 57 insertions(+), 67 deletions(-) diff --git a/chrome/content/zotero/xpcom/connector/translate_item.js b/chrome/content/zotero/xpcom/connector/translate_item.js index 60803612f..545ae86da 100644 --- a/chrome/content/zotero/xpcom/connector/translate_item.js +++ b/chrome/content/zotero/xpcom/connector/translate_item.js @@ -106,8 +106,6 @@ Zotero.Translate.ItemSaver.prototype = { }); }, - // ALL CODE BELOW THIS POINT IS EXECUTED ONLY IN NON-FIREFOX ENVIRONMENTS - /** * Polls for updates to attachment progress * @param items Items in Zotero.Item.toArray() format @@ -162,6 +160,8 @@ Zotero.Translate.ItemSaver.prototype = { poll(); }, + // ALL CODE BELOW THIS POINT IS EXECUTED ONLY IN NON-FIREFOX ENVIRONMENTS + /** * Saves items to server * @param items Items in Zotero.Item.toArray() format @@ -182,7 +182,7 @@ Zotero.Translate.ItemSaver.prototype = { for(var i=0, n=items.length; i Date: Thu, 15 Aug 2013 15:50:44 -0400 Subject: [PATCH 8/8] Call done handler after saving Broken by dde09c54a201a4298815135cdd0eb76903992234 --- chrome/content/zotero/xpcom/translation/translate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index b55ea26c2..bfa2fb37a 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -1413,7 +1413,7 @@ Zotero.Translate.Base.prototype = { * Checks if saving done, and if so, fires done event */ "_checkIfDone":function() { - if(!this._savingItems && !this._savingAttachments.length && !this._currentState) { + if(!this._savingItems && !this._savingAttachments.length) { this._runHandler("done", true); } },