commit 5901a3c7af33a9a32dc921a7c24ae9f85bdef8e5
parent 14f40218a922a2eca69d141870c99bc2edc1469d
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 26 Oct 2017 19:04:38 -0400
Fix possible skipped group download when another group is archived
Diffstat:
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/chrome/content/zotero/xpcom/sync/syncRunner.js b/chrome/content/zotero/xpcom/sync/syncRunner.js
@@ -371,10 +371,8 @@ Zotero.Sync.Runner_Module = function (options = {}) {
}
let remoteGroupVersions = yield client.getGroupVersions(keyInfo.userID);
- Zotero.debug(remoteGroupVersions);
let remoteGroupIDs = Object.keys(remoteGroupVersions).map(id => parseInt(id));
let skippedGroups = Zotero.Sync.Data.Local.getSkippedGroups();
- Zotero.debug(skippedGroups);
// Remove skipped groups
if (syncAllLibraries) {
@@ -456,9 +454,9 @@ Zotero.Sync.Runner_Module = function (options = {}) {
//
// TODO: Localize
for (let group of remotelyMissingGroups) {
- // Ignore archived groups
+ // Ignore remotely missing archived groups
if (group.archived) {
- groupsToDownload.splice(groupsToDownload.indexOf(group.id), 1);
+ groupsToDownload = groupsToDownload.filter(groupID => groupID != group.id);
continue;
}
diff --git a/test/tests/syncRunnerTest.js b/test/tests/syncRunnerTest.js
@@ -296,12 +296,12 @@ describe("Zotero.Sync.Runner", function () {
});
it("should filter out remotely missing archived libraries if library list not provided", function* () {
- var syncedGroupID = responses.groups.ownerGroup.json.id;
+ var ownerGroupID = responses.groups.ownerGroup.json.id;
var archivedGroupID = 162512451; // nonexistent group id
- var syncedGroup = yield createGroup({
- id: syncedGroupID,
- version: responses.groups.ownerGroup.json.version - 1
+ var ownerGroup = yield createGroup({
+ id: ownerGroupID,
+ version: responses.groups.ownerGroup.json.version
});
var archivedGroup = yield createGroup({
id: archivedGroupID,
@@ -310,15 +310,23 @@ describe("Zotero.Sync.Runner", function () {
});
setResponse('userGroups.groupVersions');
- setResponse('groups.ownerGroup');
+ setResponse('groups.memberGroup');
var libraries = yield runner.checkLibraries(
runner.getAPIClient({ apiKey }),
false,
responses.keyInfo.fullAccess.json
);
- assert.lengthOf(libraries, 2);
- assert.sameMembers(libraries, [userLibraryID, syncedGroup.libraryID]);
+ assert.lengthOf(libraries, 3);
+ assert.sameMembers(
+ libraries,
+ [
+ userLibraryID,
+ ownerGroup.libraryID,
+ // Nonexistent group should've been created
+ Zotero.Groups.getLibraryIDFromGroupID(responses.groups.memberGroup.json.id)
+ ]
+ );
});
it("should unarchive library if available remotely", function* () {