Fix sync error from items dragged between libraries before first sync
And fix bug in Zotero.URI.getURILibrary()
This commit is contained in:
parent
318528df4d
commit
687ee6ba07
|
@ -486,8 +486,6 @@ Zotero.Sync.Runner_Module = function (options = {}) {
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(function* () {
|
||||||
if (lastUserID != userID) {
|
if (lastUserID != userID) {
|
||||||
yield Zotero.Users.setCurrentUserID(userID);
|
|
||||||
|
|
||||||
if (lastUserID) {
|
if (lastUserID) {
|
||||||
// Delete all local groups if changing users
|
// Delete all local groups if changing users
|
||||||
for (let group of groups) {
|
for (let group of groups) {
|
||||||
|
@ -495,14 +493,15 @@ Zotero.Sync.Runner_Module = function (options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update relations pointing to the old library to point to this one
|
// Update relations pointing to the old library to point to this one
|
||||||
yield Zotero.Relations.updateUser(lastUserID, userID);
|
yield Zotero.Relations.updateUser(userID);
|
||||||
}
|
}
|
||||||
// Replace local user key with libraryID, in case duplicates were
|
// Replace local user key with libraryID, in case duplicates were
|
||||||
// merged before the first sync
|
// merged before the first sync
|
||||||
else {
|
else {
|
||||||
let repl = "local/" + Zotero.Users.getLocalUserKey();
|
yield Zotero.Relations.updateUser(userID);
|
||||||
yield Zotero.Relations.updateUser(repl, userID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yield Zotero.Users.setCurrentUserID(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastUsername != username) {
|
if (lastUsername != username) {
|
||||||
|
|
|
@ -262,7 +262,7 @@ Zotero.URI = new function () {
|
||||||
*/
|
*/
|
||||||
this.getURILibrary = function (libraryURI) {
|
this.getURILibrary = function (libraryURI) {
|
||||||
let library = this._getURIObjectLibrary(libraryURI);
|
let library = this._getURIObjectLibrary(libraryURI);
|
||||||
return libraryID ? library.libraryID : false;
|
return library ? library.id : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -439,6 +439,28 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
assert.equal(Zotero.Users.getCurrentUserID(), 1);
|
assert.equal(Zotero.Users.getCurrentUserID(), 1);
|
||||||
assert.equal(Zotero.Users.getCurrentUsername(), "A");
|
assert.equal(Zotero.Users.getCurrentUsername(), "A");
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should update local relations when syncing for the first time", function* () {
|
||||||
|
yield resetDB({
|
||||||
|
thisArg: this,
|
||||||
|
skipBundledFiles: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var item1 = yield createDataObject('item');
|
||||||
|
var item2 = yield createDataObject(
|
||||||
|
'item', { libraryID: Zotero.Libraries.publicationsLibraryID }
|
||||||
|
);
|
||||||
|
|
||||||
|
yield item1.addLinkedItem(item2);
|
||||||
|
|
||||||
|
var cont = yield runner.checkUser(1, "A");
|
||||||
|
assert.isTrue(cont);
|
||||||
|
|
||||||
|
var json = yield item1.toJSON();
|
||||||
|
var uri = json.relations[Zotero.Relations.linkedObjectPredicate][0];
|
||||||
|
assert.notInclude(uri, 'users/local');
|
||||||
|
assert.include(uri, 'users/1/publications');
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("#sync()", function () {
|
describe("#sync()", function () {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user