Update Zotero.Sync.Storage.QueueManager.start() for async item.clone()

Via _reconcileConflicts()
This commit is contained in:
Dan Stillman 2015-03-18 22:41:46 -04:00
parent bb3496dfa8
commit 304f46c8cc

View File

@ -28,7 +28,7 @@ Zotero.Sync.Storage.QueueManager = new function () {
var _queues = {}; var _queues = {};
var _currentQueues = []; var _currentQueues = [];
this.start = function (libraryID) { this.start = Zotero.Promise.coroutine(function* (libraryID) {
if (libraryID) { if (libraryID) {
var queues = this.getAll(libraryID); var queues = this.getAll(libraryID);
var suffix = " for library " + libraryID; var suffix = " for library " + libraryID;
@ -53,27 +53,27 @@ Zotero.Sync.Storage.QueueManager = new function () {
Zotero.debug("No files to sync" + suffix); Zotero.debug("No files to sync" + suffix);
} }
return Zotero.Promise.allSettled(promises) var results = yield Zotero.Promise.allSettled(promises);
.then(function (results) { Zotero.debug("All storage queues are finished" + suffix);
Zotero.debug("All storage queues are finished" + suffix);
results.forEach(function (result) { for (let i = 0; i < results.length; i++) {
// Check for conflicts to resolve let result = results[i];
if (result.state == "fulfilled") { // Check for conflicts to resolve
result = result.value; if (result.state == "fulfilled") {
if (result.conflicts.length) { result = result.value;
Zotero.debug("Reconciling conflicts for library " + result.libraryID); if (result.conflicts.length) {
Zotero.debug(result.conflicts); Zotero.debug("Reconciling conflicts for library " + result.libraryID);
var data = _reconcileConflicts(result.conflicts); Zotero.debug(result.conflicts);
if (data) { var data = yield _reconcileConflicts(result.conflicts);
_processMergeData(data); if (data) {
} _processMergeData(data);
} }
} }
}); }
return promises; }
});
}; return promises;
});
this.stop = function (libraryID) { this.stop = function (libraryID) {
if (libraryID) { if (libraryID) {