From b09daebbde01fc2a0d36500eeb8e6e0ea6fc6a00 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 30 Apr 2013 17:48:01 -0400 Subject: [PATCH] Don't try to upload files if no file editing access for library This should fix https://forums.zotero.org/discussion/29149/ and probably some other things. --- chrome/content/zotero/xpcom/data/libraries.js | 24 +++++++++++++++++++ chrome/content/zotero/xpcom/storage.js | 11 ++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/libraries.js b/chrome/content/zotero/xpcom/data/libraries.js index e631f85bd..9150ddaf7 100644 --- a/chrome/content/zotero/xpcom/data/libraries.js +++ b/chrome/content/zotero/xpcom/data/libraries.js @@ -78,6 +78,9 @@ Zotero.Libraries = new function () { this.isEditable = function (libraryID) { var type = this.getType(libraryID); switch (type) { + case 'user': + return true; + case 'group': var groupID = Zotero.Groups.getGroupIDFromLibraryID(libraryID); var group = Zotero.Groups.get(groupID); @@ -87,4 +90,25 @@ Zotero.Libraries = new function () { throw ("Unsupported library type '" + type + "' in Zotero.Libraries.getName()"); } } + + + this.isFilesEditable = function (libraryID) { + if (!this.isEditable(libraryID)) { + return false; + } + + var type = this.getType(libraryID); + switch (type) { + case 'user': + return true; + + case 'group': + var groupID = Zotero.Groups.getGroupIDFromLibraryID(libraryID); + var group = Zotero.Groups.get(groupID); + return group.filesEditable; + + default: + throw ("Unsupported library type '" + type + "' in Zotero.Libraries.getName()"); + } + } } diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index aff118801..a1771b6c1 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -263,9 +263,14 @@ Zotero.Sync.Storage = new function () { } // Get files to upload - for each(var itemID in _getFilesToUpload(libraryID)) { - var item = Zotero.Items.get(itemID); - self.queueItem(item); + if (Zotero.Libraries.isFilesEditable(libraryID)) { + for each(var itemID in _getFilesToUpload(libraryID)) { + var item = Zotero.Items.get(itemID); + self.queueItem(item); + } + } + else { + Zotero.debug("No file editing access -- skipping file uploads for library " + libraryID); } }