www

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

commit 90286d2a509e5fa2d36b8c15d0e3687fa3041e87
parent 3fca0644ee2eac79600d199bffa0924ddf16cd72
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu, 29 Oct 2015 02:27:33 -0400

Make Zotero.Item::attachmentHash getter asynchronous

Diffstat:
Mchrome/content/zotero/xpcom/data/item.js | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -2751,10 +2751,10 @@ Zotero.defineProperty(Zotero.Item.prototype, 'attachmentModificationTime', { * Note: This is the hash of the file itself, not the last-known hash * of the file on the storage server as stored in the database * - * @return {String} MD5 hash of file as hex string + * @return {Promise<String>} - MD5 hash of file as hex string */ Zotero.defineProperty(Zotero.Item.prototype, 'attachmentHash', { - get: function () { + get: Zotero.Promise.coroutine(function* () { if (!this.isAttachment()) { return undefined; } @@ -2763,13 +2763,13 @@ Zotero.defineProperty(Zotero.Item.prototype, 'attachmentHash', { return undefined; } - var file = this.getFile(); - if (!file) { + var path = yield this.getFilePathAsync(); + if (!path) { return undefined; } - return Zotero.Utilities.Internal.md5(file) || undefined; - } + return Zotero.Utilities.Internal.md5Async(path); + }) }); @@ -3894,7 +3894,7 @@ Zotero.Item.prototype.toJSON = Zotero.Promise.coroutine(function* (options = {}) } if (this.isFileAttachment()) { - obj.md5 = this.attachmentHash; + obj.md5 = yield this.attachmentHash; obj.mtime = yield this.attachmentModificationTime; } }