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.
This commit is contained in:
Dan Stillman 2013-04-30 17:48:01 -04:00
parent cb7070cc4e
commit b09daebbde
2 changed files with 32 additions and 3 deletions

View File

@ -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()");
}
}
}

View File

@ -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);
}
}