fx-compat: DB.executeTransaction() no longer takes generator functions
This commit is contained in:
parent
ccbc785499
commit
03242e8984
41 changed files with 319 additions and 320 deletions
|
@ -223,15 +223,15 @@
|
||||||
ps.alert(null, "", "You cannot relate items in different libraries.");
|
ps.alert(null, "", "You cannot relate items in different libraries.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let relItem of relItems) {
|
for (let relItem of relItems) {
|
||||||
if (this.item.addRelatedItem(relItem)) {
|
if (this.item.addRelatedItem(relItem)) {
|
||||||
yield this.item.save({
|
await this.item.save({
|
||||||
skipDateModifiedUpdate: true
|
skipDateModifiedUpdate: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (relItem.addRelatedItem(this.item)) {
|
if (relItem.addRelatedItem(this.item)) {
|
||||||
yield relItem.save({
|
await relItem.save({
|
||||||
skipDateModifiedUpdate: true
|
skipDateModifiedUpdate: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -246,14 +246,14 @@
|
||||||
return Zotero.spawn(function* () {
|
return Zotero.spawn(function* () {
|
||||||
var item = yield Zotero.Items.getAsync(id);
|
var item = yield Zotero.Items.getAsync(id);
|
||||||
if (item) {
|
if (item) {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
if (this.item.removeRelatedItem(item)) {
|
if (this.item.removeRelatedItem(item)) {
|
||||||
yield this.item.save({
|
await this.item.save({
|
||||||
skipDateModifiedUpdate: true
|
skipDateModifiedUpdate: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (item.removeRelatedItem(this.item)) {
|
if (item.removeRelatedItem(this.item)) {
|
||||||
yield item.save({
|
await item.save({
|
||||||
skipDateModifiedUpdate: true
|
skipDateModifiedUpdate: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -576,7 +576,7 @@ Zotero.TagSelector = class TagSelectorContainer extends React.PureComponent {
|
||||||
// Remove tags on Cmd-drag/Shift-drag
|
// Remove tags on Cmd-drag/Shift-drag
|
||||||
var remove = (Zotero.isMac && event.metaKey) || (!Zotero.isMac && event.shiftKey);
|
var remove = (Zotero.isMac && event.metaKey) || (!Zotero.isMac && event.shiftKey);
|
||||||
|
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
ids = ids.split(',');
|
ids = ids.split(',');
|
||||||
var items = Zotero.Items.get(ids);
|
var items = Zotero.Items.get(ids);
|
||||||
var value = elem.textContent;
|
var value = elem.textContent;
|
||||||
|
@ -589,7 +589,7 @@ Zotero.TagSelector = class TagSelectorContainer extends React.PureComponent {
|
||||||
else {
|
else {
|
||||||
item.addTag(value);
|
item.addTag(value);
|
||||||
}
|
}
|
||||||
yield item.save();
|
await item.save();
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -850,7 +850,7 @@ Zotero_Preferences.Attachment_Base_Directory = {
|
||||||
Object.keys(newAttachmentPaths),
|
Object.keys(newAttachmentPaths),
|
||||||
100,
|
100,
|
||||||
function (chunk) {
|
function (chunk) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
for (let id of chunk) {
|
for (let id of chunk) {
|
||||||
let attachment = Zotero.Items.get(id);
|
let attachment = Zotero.Items.get(id);
|
||||||
if (newAttachmentPaths[id]) {
|
if (newAttachmentPaths[id]) {
|
||||||
|
@ -859,7 +859,7 @@ Zotero_Preferences.Attachment_Base_Directory = {
|
||||||
else {
|
else {
|
||||||
attachment.attachmentPath = attachment.getFilePath();
|
attachment.attachmentPath = attachment.getFilePath();
|
||||||
}
|
}
|
||||||
yield attachment.save({
|
await attachment.save({
|
||||||
skipDateModifiedUpdate: true
|
skipDateModifiedUpdate: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -927,11 +927,11 @@ Zotero_Preferences.Attachment_Base_Directory = {
|
||||||
relativeAttachmentIDs,
|
relativeAttachmentIDs,
|
||||||
100,
|
100,
|
||||||
function (chunk) {
|
function (chunk) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
for (let id of chunk) {
|
for (let id of chunk) {
|
||||||
let attachment = yield Zotero.Items.getAsync(id);
|
let attachment = await Zotero.Items.getAsync(id);
|
||||||
attachment.attachmentPath = attachment.getFilePath();
|
attachment.attachmentPath = attachment.getFilePath();
|
||||||
yield attachment.save({
|
await attachment.save({
|
||||||
skipDateModifiedUpdate: true
|
skipDateModifiedUpdate: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -722,10 +722,10 @@ Zotero_Preferences.Sync = {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
let libraries = Zotero.Libraries.getAll().filter(library => library.syncable);
|
let libraries = Zotero.Libraries.getAll().filter(library => library.syncable);
|
||||||
await Zotero.DB.executeTransaction(function* () {
|
await Zotero.DB.executeTransaction(async function () {
|
||||||
for (let library of libraries) {
|
for (let library of libraries) {
|
||||||
library.libraryVersion = -1;
|
library.libraryVersion = -1;
|
||||||
yield library.save();
|
await library.save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -84,7 +84,7 @@ Zotero.Attachments = new function(){
|
||||||
|
|
||||||
var attachmentItem, itemID, newFile, contentType, destDir;
|
var attachmentItem, itemID, newFile, contentType, destDir;
|
||||||
try {
|
try {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
// Create a new attachment
|
// Create a new attachment
|
||||||
attachmentItem = new Zotero.Item('attachment');
|
attachmentItem = new Zotero.Item('attachment');
|
||||||
if (parentItemID) {
|
if (parentItemID) {
|
||||||
|
@ -101,34 +101,34 @@ Zotero.Attachments = new function(){
|
||||||
if (collections) {
|
if (collections) {
|
||||||
attachmentItem.setCollections(collections);
|
attachmentItem.setCollections(collections);
|
||||||
}
|
}
|
||||||
yield attachmentItem.save(saveOptions);
|
await attachmentItem.save(saveOptions);
|
||||||
|
|
||||||
// Create directory for attachment files within storage directory
|
// Create directory for attachment files within storage directory
|
||||||
destDir = yield this.createDirectoryForItem(attachmentItem);
|
destDir = await this.createDirectoryForItem(attachmentItem);
|
||||||
|
|
||||||
// Point to copied file
|
// Point to copied file
|
||||||
newFile = OS.Path.join(destDir, newName);
|
newFile = OS.Path.join(destDir, newName);
|
||||||
|
|
||||||
// Copy or move file to unique filename, which automatically shortens long filenames
|
// Copy or move file to unique filename, which automatically shortens long filenames
|
||||||
if (options.moveFile) {
|
if (options.moveFile) {
|
||||||
const newFilePath = yield Zotero.File.moveToUnique(file.path, newFile);
|
const newFilePath = await Zotero.File.moveToUnique(file.path, newFile);
|
||||||
newFile = Zotero.File.pathToFile(newFilePath);
|
newFile = Zotero.File.pathToFile(newFilePath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newFile = Zotero.File.copyToUnique(file, newFile);
|
newFile = Zotero.File.copyToUnique(file, newFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
yield Zotero.File.setNormalFilePermissions(newFile.path);
|
await Zotero.File.setNormalFilePermissions(newFile.path);
|
||||||
|
|
||||||
if (!contentType) {
|
if (!contentType) {
|
||||||
contentType = yield Zotero.MIME.getMIMETypeFromFile(newFile);
|
contentType = await Zotero.MIME.getMIMETypeFromFile(newFile);
|
||||||
}
|
}
|
||||||
attachmentItem.attachmentContentType = contentType;
|
attachmentItem.attachmentContentType = contentType;
|
||||||
if (charset) {
|
if (charset) {
|
||||||
attachmentItem.attachmentCharset = charset;
|
attachmentItem.attachmentCharset = charset;
|
||||||
}
|
}
|
||||||
attachmentItem.attachmentPath = newFile.path;
|
attachmentItem.attachmentPath = newFile.path;
|
||||||
yield attachmentItem.save(saveOptions);
|
await attachmentItem.save(saveOptions);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
try {
|
try {
|
||||||
yield _postProcessFile(attachmentItem, newFile, contentType);
|
yield _postProcessFile(attachmentItem, newFile, contentType);
|
||||||
|
@ -296,7 +296,7 @@ Zotero.Attachments = new function(){
|
||||||
|
|
||||||
var attachmentItem, itemID, destDir, newPath;
|
var attachmentItem, itemID, destDir, newPath;
|
||||||
try {
|
try {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
// Create a new attachment
|
// Create a new attachment
|
||||||
attachmentItem = new Zotero.Item('attachment');
|
attachmentItem = new Zotero.Item('attachment');
|
||||||
let {libraryID, key: parentKey} = Zotero.Items.getLibraryAndKeyFromID(parentItemID);
|
let {libraryID, key: parentKey} = Zotero.Items.getLibraryAndKeyFromID(parentItemID);
|
||||||
|
@ -312,20 +312,20 @@ Zotero.Attachments = new function(){
|
||||||
// DEBUG: this should probably insert access date too so as to
|
// DEBUG: this should probably insert access date too so as to
|
||||||
// create a proper item, but at the moment this is only called by
|
// create a proper item, but at the moment this is only called by
|
||||||
// translate.js, which sets the metadata fields itself
|
// translate.js, which sets the metadata fields itself
|
||||||
itemID = yield attachmentItem.save(saveOptions);
|
itemID = await attachmentItem.save(saveOptions);
|
||||||
|
|
||||||
var storageDir = Zotero.getStorageDirectory();
|
var storageDir = Zotero.getStorageDirectory();
|
||||||
destDir = this.getStorageDirectory(attachmentItem);
|
destDir = this.getStorageDirectory(attachmentItem);
|
||||||
yield OS.File.removeDir(destDir.path);
|
await OS.File.removeDir(destDir.path);
|
||||||
newPath = OS.Path.join(destDir.path, fileName);
|
newPath = OS.Path.join(destDir.path, fileName);
|
||||||
// Copy single file to new directory
|
// Copy single file to new directory
|
||||||
if (options.singleFile) {
|
if (options.singleFile) {
|
||||||
yield this.createDirectoryForItem(attachmentItem);
|
await this.createDirectoryForItem(attachmentItem);
|
||||||
if (options.moveFile) {
|
if (options.moveFile) {
|
||||||
yield OS.File.move(file.path, newPath);
|
await OS.File.move(file.path, newPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield OS.File.copy(file.path, newPath);
|
await OS.File.copy(file.path, newPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Copy entire parent directory (for HTML snapshots)
|
// Copy entire parent directory (for HTML snapshots)
|
||||||
|
@ -928,7 +928,7 @@ Zotero.Attachments = new function(){
|
||||||
|
|
||||||
var attachmentItem;
|
var attachmentItem;
|
||||||
var destDir;
|
var destDir;
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
// Create a new attachment
|
// Create a new attachment
|
||||||
attachmentItem = new Zotero.Item('attachment');
|
attachmentItem = new Zotero.Item('attachment');
|
||||||
if (libraryID) {
|
if (libraryID) {
|
||||||
|
@ -950,12 +950,12 @@ Zotero.Attachments = new function(){
|
||||||
attachmentItem.setCollections(collections);
|
attachmentItem.setCollections(collections);
|
||||||
}
|
}
|
||||||
attachmentItem.attachmentPath = 'storage:' + fileName;
|
attachmentItem.attachmentPath = 'storage:' + fileName;
|
||||||
var itemID = yield attachmentItem.save(saveOptions);
|
var itemID = await attachmentItem.save(saveOptions);
|
||||||
|
|
||||||
Zotero.Fulltext.queueItem(attachmentItem);
|
Zotero.Fulltext.queueItem(attachmentItem);
|
||||||
|
|
||||||
destDir = this.getStorageDirectory(attachmentItem).path;
|
destDir = this.getStorageDirectory(attachmentItem).path;
|
||||||
yield OS.File.move(tmpDir, destDir);
|
await OS.File.move(tmpDir, destDir);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
@ -2876,7 +2876,7 @@ Zotero.Attachments = new function(){
|
||||||
var collections = options.collections;
|
var collections = options.collections;
|
||||||
var saveOptions = options.saveOptions;
|
var saveOptions = options.saveOptions;
|
||||||
|
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
var attachmentItem = new Zotero.Item('attachment');
|
var attachmentItem = new Zotero.Item('attachment');
|
||||||
if (parentItemID) {
|
if (parentItemID) {
|
||||||
let {libraryID: parentLibraryID, key: parentKey} =
|
let {libraryID: parentLibraryID, key: parentKey} =
|
||||||
|
@ -2904,7 +2904,7 @@ Zotero.Attachments = new function(){
|
||||||
if (collections) {
|
if (collections) {
|
||||||
attachmentItem.setCollections(collections);
|
attachmentItem.setCollections(collections);
|
||||||
}
|
}
|
||||||
yield attachmentItem.save(saveOptions);
|
await attachmentItem.save(saveOptions);
|
||||||
|
|
||||||
return attachmentItem;
|
return attachmentItem;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
|
@ -936,10 +936,10 @@ Zotero.DataObject.prototype.save = Zotero.Promise.coroutine(function* (options =
|
||||||
// Create transaction
|
// Create transaction
|
||||||
let result
|
let result
|
||||||
if (env.options.tx) {
|
if (env.options.tx) {
|
||||||
result = yield Zotero.DB.executeTransaction(function* () {
|
result = yield Zotero.DB.executeTransaction(async function () {
|
||||||
Zotero.DataObject.prototype._saveData.call(this, env);
|
Zotero.DataObject.prototype._saveData.call(this, env);
|
||||||
yield this._saveData(env);
|
await this._saveData(env);
|
||||||
yield Zotero.DataObject.prototype._finalizeSave.call(this, env);
|
await Zotero.DataObject.prototype._finalizeSave.call(this, env);
|
||||||
return this._finalizeSave(env);
|
return this._finalizeSave(env);
|
||||||
}.bind(this), env.transactionOptions);
|
}.bind(this), env.transactionOptions);
|
||||||
}
|
}
|
||||||
|
@ -1261,9 +1261,9 @@ Zotero.DataObject.prototype.erase = Zotero.Promise.coroutine(function* (options
|
||||||
Zotero.debug('Deleting ' + this.objectType + ' ' + this.id);
|
Zotero.debug('Deleting ' + this.objectType + ' ' + this.id);
|
||||||
|
|
||||||
if (env.options.tx) {
|
if (env.options.tx) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
yield this._eraseData(env);
|
await this._eraseData(env);
|
||||||
yield this._finalizeErase(env);
|
await this._finalizeErase(env);
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1110,13 +1110,13 @@ Zotero.DataObjects.prototype.getPrimaryDataSQLPart = function (part) {
|
||||||
*/
|
*/
|
||||||
Zotero.DataObjects.prototype.erase = Zotero.Promise.coroutine(function* (ids, options = {}) {
|
Zotero.DataObjects.prototype.erase = Zotero.Promise.coroutine(function* (ids, options = {}) {
|
||||||
ids = Zotero.flattenArguments(ids);
|
ids = Zotero.flattenArguments(ids);
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let i = 0; i < ids.length; i++) {
|
for (let i = 0; i < ids.length; i++) {
|
||||||
let obj = yield this.getAsync(ids[i]);
|
let obj = await this.getAsync(ids[i]);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
yield obj.erase(options);
|
await obj.erase(options);
|
||||||
if (options.onProgress) {
|
if (options.onProgress) {
|
||||||
options.onProgress(i + 1, ids.length);
|
options.onProgress(i + 1, ids.length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -487,10 +487,10 @@ Zotero.Feed.prototype._updateFeed = Zotero.Promise.coroutine(function* () {
|
||||||
this._set('_feedLastCheckError', e.message || 'Error processing feed');
|
this._set('_feedLastCheckError', e.message || 'Error processing feed');
|
||||||
}
|
}
|
||||||
if (toSave.length) {
|
if (toSave.length) {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
// Save in reverse order
|
// Save in reverse order
|
||||||
for (let i=toSave.length-1; i>=0; i--) {
|
for (let i=toSave.length-1; i>=0; i--) {
|
||||||
yield toSave[i].save();
|
await toSave[i].save();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -145,9 +145,9 @@ Zotero.Feeds = new function() {
|
||||||
newFeeds.push(feed);
|
newFeeds.push(feed);
|
||||||
}
|
}
|
||||||
// This could potentially be a massive list, so we save in a transaction.
|
// This could potentially be a massive list, so we save in a transaction.
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let feed of newFeeds) {
|
for (let feed of newFeeds) {
|
||||||
yield feed.save({
|
await feed.save({
|
||||||
skipSelect: true
|
skipSelect: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -460,11 +460,11 @@ Zotero.Items = function() {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (notesToUpdate.length) {
|
if (notesToUpdate.length) {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let i = 0; i < notesToUpdate.length; i++) {
|
for (let i = 0; i < notesToUpdate.length; i++) {
|
||||||
let row = notesToUpdate[i];
|
let row = notesToUpdate[i];
|
||||||
let sql = "UPDATE itemNotes SET note=? WHERE itemID=?";
|
let sql = "UPDATE itemNotes SET note=? WHERE itemID=?";
|
||||||
yield Zotero.DB.queryAsync(sql, [row[1], row[0]]);
|
await Zotero.DB.queryAsync(sql, [row[1], row[0]]);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
@ -947,16 +947,16 @@ Zotero.Items = function() {
|
||||||
this.merge = function (item, otherItems) {
|
this.merge = function (item, otherItems) {
|
||||||
Zotero.debug("Merging items");
|
Zotero.debug("Merging items");
|
||||||
|
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
var replPred = Zotero.Relations.replacedItemPredicate;
|
var replPred = Zotero.Relations.replacedItemPredicate;
|
||||||
var toSave = {};
|
var toSave = {};
|
||||||
toSave[item.id] = item;
|
toSave[item.id] = item;
|
||||||
|
|
||||||
var earliestDateAdded = item.dateAdded;
|
var earliestDateAdded = item.dateAdded;
|
||||||
|
|
||||||
let remapAttachmentKeys = yield this._mergePDFAttachments(item, otherItems);
|
let remapAttachmentKeys = await this._mergePDFAttachments(item, otherItems);
|
||||||
yield this._mergeWebAttachments(item, otherItems);
|
await this._mergeWebAttachments(item, otherItems);
|
||||||
yield this._mergeOtherAttachments(item, otherItems);
|
await this._mergeOtherAttachments(item, otherItems);
|
||||||
|
|
||||||
for (let otherItem of otherItems) {
|
for (let otherItem of otherItems) {
|
||||||
if (otherItem.libraryID !== item.libraryID) {
|
if (otherItem.libraryID !== item.libraryID) {
|
||||||
|
@ -971,7 +971,7 @@ Zotero.Items = function() {
|
||||||
// Move notes to master
|
// Move notes to master
|
||||||
var noteIDs = otherItem.getNotes(true);
|
var noteIDs = otherItem.getNotes(true);
|
||||||
for (let id of noteIDs) {
|
for (let id of noteIDs) {
|
||||||
var note = yield this.getAsync(id);
|
var note = await this.getAsync(id);
|
||||||
note.parentItemID = item.id;
|
note.parentItemID = item.id;
|
||||||
Zotero.Notes.replaceItemKey(note, otherItem.key, item.key);
|
Zotero.Notes.replaceItemKey(note, otherItem.key, item.key);
|
||||||
Zotero.Notes.replaceAllItemKeys(note, remapAttachmentKeys);
|
Zotero.Notes.replaceAllItemKeys(note, remapAttachmentKeys);
|
||||||
|
@ -979,9 +979,8 @@ Zotero.Items = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move relations to master
|
// Move relations to master
|
||||||
yield this._moveRelations(otherItem, item);
|
await this._moveRelations(otherItem, item);
|
||||||
|
|
||||||
// All other operations are additive only and do not affect the
|
|
||||||
// old item, which will be put in the trash
|
// old item, which will be put in the trash
|
||||||
|
|
||||||
// Add collections to master
|
// Add collections to master
|
||||||
|
@ -1016,10 +1015,10 @@ Zotero.Items = function() {
|
||||||
|
|
||||||
// Hack to remove master item from duplicates view without recalculating duplicates
|
// Hack to remove master item from duplicates view without recalculating duplicates
|
||||||
// Pass force = true so observers will be notified before this transaction is committed
|
// Pass force = true so observers will be notified before this transaction is committed
|
||||||
yield Zotero.Notifier.trigger('removeDuplicatesMaster', 'item', item.id, null, true);
|
await Zotero.Notifier.trigger('removeDuplicatesMaster', 'item', item.id, null, true);
|
||||||
|
|
||||||
for (let i in toSave) {
|
for (let i in toSave) {
|
||||||
yield toSave[i].save();
|
await toSave[i].save();
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
|
@ -1416,7 +1415,7 @@ Zotero.Items = function() {
|
||||||
|
|
||||||
|
|
||||||
this.trashTx = function (ids) {
|
this.trashTx = function (ids) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
return this.trash(ids);
|
return this.trash(ids);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
@ -1542,7 +1541,7 @@ Zotero.Items = function() {
|
||||||
this.addToPublications = function (items, options = {}) {
|
this.addToPublications = function (items, options = {}) {
|
||||||
if (!items.length) return;
|
if (!items.length) return;
|
||||||
|
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
var timestamp = Zotero.DB.transactionTimestamp;
|
var timestamp = Zotero.DB.transactionTimestamp;
|
||||||
|
|
||||||
var allItems = [...items];
|
var allItems = [...items];
|
||||||
|
@ -1586,7 +1585,7 @@ Zotero.Items = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
yield Zotero.Utilities.Internal.forEachChunkAsync(allItems, 250, Zotero.Promise.coroutine(function* (chunk) {
|
await Zotero.Utilities.Internal.forEachChunkAsync(allItems, 250, Zotero.Promise.coroutine(function* (chunk) {
|
||||||
for (let item of chunk) {
|
for (let item of chunk) {
|
||||||
item.setPublications(true);
|
item.setPublications(true);
|
||||||
item.synced = false;
|
item.synced = false;
|
||||||
|
@ -1606,7 +1605,7 @@ Zotero.Items = function() {
|
||||||
|
|
||||||
|
|
||||||
this.removeFromPublications = function (items) {
|
this.removeFromPublications = function (items) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
let allItems = [];
|
let allItems = [];
|
||||||
for (let item of items) {
|
for (let item of items) {
|
||||||
if (!item.inPublications) {
|
if (!item.inPublications) {
|
||||||
|
@ -1627,7 +1626,7 @@ Zotero.Items = function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var timestamp = Zotero.DB.transactionTimestamp;
|
var timestamp = Zotero.DB.transactionTimestamp;
|
||||||
yield Zotero.Utilities.Internal.forEachChunkAsync(allItems, 250, Zotero.Promise.coroutine(function* (chunk) {
|
await Zotero.Utilities.Internal.forEachChunkAsync(allItems, 250, Zotero.Promise.coroutine(function* (chunk) {
|
||||||
let idStr = chunk.map(item => item.id).join(", ");
|
let idStr = chunk.map(item => item.id).join(", ");
|
||||||
yield Zotero.DB.queryAsync(
|
yield Zotero.DB.queryAsync(
|
||||||
`UPDATE items SET synced=0, clientDateModified=? WHERE itemID IN (${idStr})`,
|
`UPDATE items SET synced=0, clientDateModified=? WHERE itemID IN (${idStr})`,
|
||||||
|
|
|
@ -462,9 +462,9 @@ Zotero.Library.prototype.save = Zotero.Promise.coroutine(function* (options) {
|
||||||
|
|
||||||
// Create transaction
|
// Create transaction
|
||||||
if (env.options.tx) {
|
if (env.options.tx) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
yield this._saveData(env);
|
await this._saveData(env);
|
||||||
yield this._finalizeSave(env);
|
await this._finalizeSave(env);
|
||||||
}.bind(this), env.transactionOptions);
|
}.bind(this), env.transactionOptions);
|
||||||
}
|
}
|
||||||
// Use existing transaction
|
// Use existing transaction
|
||||||
|
@ -598,9 +598,9 @@ Zotero.Library.prototype.erase = Zotero.Promise.coroutine(function* (options) {
|
||||||
env.notifierData = {};
|
env.notifierData = {};
|
||||||
|
|
||||||
if (env.options.tx) {
|
if (env.options.tx) {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield this._eraseData(env);
|
await this._eraseData(env);
|
||||||
yield this._finalizeErase(env);
|
await this._finalizeErase(env);
|
||||||
}.bind(this), env.transactionOptions);
|
}.bind(this), env.transactionOptions);
|
||||||
} else {
|
} else {
|
||||||
Zotero.DB.requireTransaction();
|
Zotero.DB.requireTransaction();
|
||||||
|
|
|
@ -247,11 +247,11 @@ Zotero.Tags = new function() {
|
||||||
// we can assign it to the new name
|
// we can assign it to the new name
|
||||||
var oldColorData = this.getColor(libraryID, oldName);
|
var oldColorData = this.getColor(libraryID, oldName);
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
var oldItemIDs = yield this.getTagItems(libraryID, oldTagID);
|
var oldItemIDs = await this.getTagItems(libraryID, oldTagID);
|
||||||
var newTagID = yield this.create(newName);
|
var newTagID = await this.create(newName);
|
||||||
|
|
||||||
yield Zotero.Utilities.Internal.forEachChunkAsync(
|
await Zotero.Utilities.Internal.forEachChunkAsync(
|
||||||
oldItemIDs,
|
oldItemIDs,
|
||||||
Zotero.DB.MAX_BOUND_PARAMETERS - 2,
|
Zotero.DB.MAX_BOUND_PARAMETERS - 2,
|
||||||
Zotero.Promise.coroutine(function* (chunk) {
|
Zotero.Promise.coroutine(function* (chunk) {
|
||||||
|
@ -291,16 +291,16 @@ Zotero.Tags = new function() {
|
||||||
notifierData
|
notifierData
|
||||||
);
|
);
|
||||||
|
|
||||||
yield this.purge(oldTagID);
|
await this.purge(oldTagID);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
if (oldColorData) {
|
if (oldColorData) {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
// Remove color from old tag
|
// Remove color from old tag
|
||||||
yield this.setColor(libraryID, oldName);
|
await this.setColor(libraryID, oldName);
|
||||||
|
|
||||||
// Add color to new tag
|
// Add color to new tag
|
||||||
yield this.setColor(
|
await this.setColor(
|
||||||
libraryID,
|
libraryID,
|
||||||
newName,
|
newName,
|
||||||
oldColorData.color,
|
oldColorData.color,
|
||||||
|
@ -335,7 +335,7 @@ Zotero.Tags = new function() {
|
||||||
tagIDs,
|
tagIDs,
|
||||||
100,
|
100,
|
||||||
async function (chunk) {
|
async function (chunk) {
|
||||||
await Zotero.DB.executeTransaction(function* () {
|
await Zotero.DB.executeTransaction(async function () {
|
||||||
var rowIDs = [];
|
var rowIDs = [];
|
||||||
var itemIDs = [];
|
var itemIDs = [];
|
||||||
var uniqueTags = new Set();
|
var uniqueTags = new Set();
|
||||||
|
@ -351,7 +351,7 @@ Zotero.Tags = new function() {
|
||||||
sql += 'AND type IN (' + types.join(', ') + ') ';
|
sql += 'AND type IN (' + types.join(', ') + ') ';
|
||||||
}
|
}
|
||||||
sql += 'ORDER BY tagID, type';
|
sql += 'ORDER BY tagID, type';
|
||||||
var rows = yield Zotero.DB.queryAsync(sql, [libraryID, ...chunk]);
|
var rows = await Zotero.DB.queryAsync(sql, [libraryID, ...chunk]);
|
||||||
for (let { rowID, tagID, itemID, type } of rows) {
|
for (let { rowID, tagID, itemID, type } of rows) {
|
||||||
uniqueTags.add(tagID);
|
uniqueTags.add(tagID);
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ Zotero.Tags = new function() {
|
||||||
// If we're deleting the tag and not just a specific type, also clear any
|
// If we're deleting the tag and not just a specific type, also clear any
|
||||||
// tag color
|
// tag color
|
||||||
if (colors.has(name) && !types) {
|
if (colors.has(name) && !types) {
|
||||||
yield this.setColor(libraryID, name, false);
|
await this.setColor(libraryID, name, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (itemIDs.length) {
|
if (itemIDs.length) {
|
||||||
|
@ -382,12 +382,12 @@ Zotero.Tags = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = "DELETE FROM itemTags WHERE ROWID IN (" + rowIDs.join(", ") + ")";
|
sql = "DELETE FROM itemTags WHERE ROWID IN (" + rowIDs.join(", ") + ")";
|
||||||
yield Zotero.DB.queryAsync(sql, false, { noCache: true });
|
await Zotero.DB.queryAsync(sql, false, { noCache: true });
|
||||||
|
|
||||||
yield this.purge(chunk);
|
await this.purge(chunk);
|
||||||
|
|
||||||
// Update internal timestamps on all items that had these tags
|
// Update internal timestamps on all items that had these tags
|
||||||
yield Zotero.Utilities.Internal.forEachChunkAsync(
|
await Zotero.Utilities.Internal.forEachChunkAsync(
|
||||||
Zotero.Utilities.arrayUnique(itemIDs),
|
Zotero.Utilities.arrayUnique(itemIDs),
|
||||||
Zotero.DB.MAX_BOUND_PARAMETERS - 1,
|
Zotero.DB.MAX_BOUND_PARAMETERS - 1,
|
||||||
async function (chunk) {
|
async function (chunk) {
|
||||||
|
|
|
@ -281,9 +281,9 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
yield Zotero.DB.waitForTransaction('indexString()');
|
yield Zotero.DB.waitForTransaction('indexString()');
|
||||||
}
|
}
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
this.clearItemWords(itemID, true);
|
this.clearItemWords(itemID, true);
|
||||||
yield indexWords(itemID, words, stats, version, synced);
|
await indexWords(itemID, words, stats, version, synced);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var sql = "REPLACE INTO fulltextContent (itemID, textContent) VALUES (?,?)";
|
var sql = "REPLACE INTO fulltextContent (itemID, textContent) VALUES (?,?)";
|
||||||
|
@ -698,8 +698,8 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
+ `${libraryKey} (contentType: ${contentType})`, 2);
|
+ `${libraryKey} (contentType: ${contentType})`, 2);
|
||||||
|
|
||||||
// Delete rows for items that weren't supposed to be indexed
|
// Delete rows for items that weren't supposed to be indexed
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield this.clearItemWords(itemID);
|
await this.clearItemWords(itemID);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,16 +388,16 @@ Zotero.Proxy.prototype.save = Zotero.Promise.coroutine(function* (transparent) {
|
||||||
this.compileRegexp();
|
this.compileRegexp();
|
||||||
|
|
||||||
if(transparent) {
|
if(transparent) {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
if(this.proxyID) {
|
if(this.proxyID) {
|
||||||
yield Zotero.DB.queryAsync(
|
await Zotero.DB.queryAsync(
|
||||||
"UPDATE proxies SET multiHost = ?, autoAssociate = ?, scheme = ? WHERE proxyID = ?",
|
"UPDATE proxies SET multiHost = ?, autoAssociate = ?, scheme = ? WHERE proxyID = ?",
|
||||||
[this.multiHost ? 1 : 0, this.autoAssociate ? 1 : 0, this.scheme, this.proxyID]
|
[this.multiHost ? 1 : 0, this.autoAssociate ? 1 : 0, this.scheme, this.proxyID]
|
||||||
);
|
);
|
||||||
yield Zotero.DB.queryAsync("DELETE FROM proxyHosts WHERE proxyID = ?", [this.proxyID]);
|
await Zotero.DB.queryAsync("DELETE FROM proxyHosts WHERE proxyID = ?", [this.proxyID]);
|
||||||
} else {
|
} else {
|
||||||
let id = Zotero.ID.get('proxies');
|
let id = Zotero.ID.get('proxies');
|
||||||
yield Zotero.DB.queryAsync(
|
await Zotero.DB.queryAsync(
|
||||||
"INSERT INTO proxies (proxyID, multiHost, autoAssociate, scheme) VALUES (?, ?, ?, ?)",
|
"INSERT INTO proxies (proxyID, multiHost, autoAssociate, scheme) VALUES (?, ?, ?, ?)",
|
||||||
[id, this.multiHost ? 1 : 0, this.autoAssociate ? 1 : 0, this.scheme]
|
[id, this.multiHost ? 1 : 0, this.autoAssociate ? 1 : 0, this.scheme]
|
||||||
);
|
);
|
||||||
|
@ -408,7 +408,7 @@ Zotero.Proxy.prototype.save = Zotero.Promise.coroutine(function* (transparent) {
|
||||||
var host;
|
var host;
|
||||||
for(var i in this.hosts) {
|
for(var i in this.hosts) {
|
||||||
host = this.hosts[i] = this.hosts[i].toLowerCase();
|
host = this.hosts[i] = this.hosts[i].toLowerCase();
|
||||||
yield Zotero.DB.queryAsync(
|
await Zotero.DB.queryAsync(
|
||||||
"INSERT INTO proxyHosts (proxyID, hostname) VALUES (?, ?)",
|
"INSERT INTO proxyHosts (proxyID, hostname) VALUES (?, ?)",
|
||||||
[this.proxyID, host]
|
[this.proxyID, host]
|
||||||
);
|
);
|
||||||
|
@ -441,9 +441,9 @@ Zotero.Proxy.prototype.erase = Zotero.Promise.coroutine(function* () {
|
||||||
Zotero.Proxies.remove(this);
|
Zotero.Proxies.remove(this);
|
||||||
|
|
||||||
if(this.proxyID) {
|
if(this.proxyID) {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.DB.queryAsync("DELETE FROM proxyHosts WHERE proxyID = ?", [this.proxyID]);
|
await Zotero.DB.queryAsync("DELETE FROM proxyHosts WHERE proxyID = ?", [this.proxyID]);
|
||||||
yield Zotero.DB.queryAsync("DELETE FROM proxies WHERE proxyID = ?", [this.proxyID]);
|
await Zotero.DB.queryAsync("DELETE FROM proxies WHERE proxyID = ?", [this.proxyID]);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -733,8 +733,8 @@ Zotero.Schema = new function(){
|
||||||
|
|
||||||
var itemTypeID = Zotero.ID.get('customItemTypes');
|
var itemTypeID = Zotero.ID.get('customItemTypes');
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO customItemTypes VALUES (?, 'nsfReviewer', 'NSF Reviewer', 1, 'chrome://zotero/skin/report_user.png')", itemTypeID);
|
await Zotero.DB.queryAsync("INSERT INTO customItemTypes VALUES (?, 'nsfReviewer', 'NSF Reviewer', 1, 'chrome://zotero/skin/report_user.png')", itemTypeID);
|
||||||
|
|
||||||
var fields = [
|
var fields = [
|
||||||
['name', 'Name'],
|
['name', 'Name'],
|
||||||
|
@ -754,11 +754,11 @@ Zotero.Schema = new function(){
|
||||||
var fieldID = Zotero.ItemFields.getID(fields[i][0]);
|
var fieldID = Zotero.ItemFields.getID(fields[i][0]);
|
||||||
if (!fieldID) {
|
if (!fieldID) {
|
||||||
var fieldID = Zotero.ID.get('customFields');
|
var fieldID = Zotero.ID.get('customFields');
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO customFields VALUES (?, ?, ?)", [fieldID, fields[i][0], fields[i][1]]);
|
await Zotero.DB.queryAsync("INSERT INTO customFields VALUES (?, ?, ?)", [fieldID, fields[i][0], fields[i][1]]);
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO customItemTypeFields VALUES (?, NULL, ?, 1, ?)", [itemTypeID, fieldID, i+1]);
|
await Zotero.DB.queryAsync("INSERT INTO customItemTypeFields VALUES (?, NULL, ?, 1, ?)", [itemTypeID, fieldID, i+1]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO customItemTypeFields VALUES (?, ?, NULL, 1, ?)", [itemTypeID, fieldID, i+1]);
|
await Zotero.DB.queryAsync("INSERT INTO customItemTypeFields VALUES (?, ?, NULL, 1, ?)", [itemTypeID, fieldID, i+1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (fields[i][0]) {
|
switch (fields[i][0]) {
|
||||||
|
@ -779,11 +779,11 @@ Zotero.Schema = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseFieldID) {
|
if (baseFieldID) {
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO customBaseFieldMappings VALUES (?, ?, ?)", [itemTypeID, baseFieldID, fieldID]);
|
await Zotero.DB.queryAsync("INSERT INTO customBaseFieldMappings VALUES (?, ?, ?)", [itemTypeID, baseFieldID, fieldID]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
yield _reloadSchema();
|
await _reloadSchema();
|
||||||
}, { disableForeignKeys: true });
|
}, { disableForeignKeys: true });
|
||||||
|
|
||||||
var s = new Zotero.Search;
|
var s = new Zotero.Search;
|
||||||
|
@ -814,25 +814,25 @@ Zotero.Schema = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.debug("Uninstalling nsfReviewer item type");
|
Zotero.debug("Uninstalling nsfReviewer item type");
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.DB.queryAsync("DELETE FROM customItemTypeFields WHERE customItemTypeID=?", itemTypeID - Zotero.ItemTypes.customIDOffset);
|
await Zotero.DB.queryAsync("DELETE FROM customItemTypeFields WHERE customItemTypeID=?", itemTypeID - Zotero.ItemTypes.customIDOffset);
|
||||||
yield Zotero.DB.queryAsync("DELETE FROM customBaseFieldMappings WHERE customItemTypeID=?", itemTypeID - Zotero.ItemTypes.customIDOffset);
|
await Zotero.DB.queryAsync("DELETE FROM customBaseFieldMappings WHERE customItemTypeID=?", itemTypeID - Zotero.ItemTypes.customIDOffset);
|
||||||
var fields = Zotero.ItemFields.getItemTypeFields(itemTypeID);
|
var fields = Zotero.ItemFields.getItemTypeFields(itemTypeID);
|
||||||
for (let fieldID of fields) {
|
for (let fieldID of fields) {
|
||||||
if (Zotero.ItemFields.isCustom(fieldID)) {
|
if (Zotero.ItemFields.isCustom(fieldID)) {
|
||||||
yield Zotero.DB.queryAsync("DELETE FROM customFields WHERE customFieldID=?", fieldID - Zotero.ItemTypes.customIDOffset);
|
await Zotero.DB.queryAsync("DELETE FROM customFields WHERE customFieldID=?", fieldID - Zotero.ItemTypes.customIDOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yield Zotero.DB.queryAsync("DELETE FROM customItemTypes WHERE customItemTypeID=?", itemTypeID - Zotero.ItemTypes.customIDOffset);
|
await Zotero.DB.queryAsync("DELETE FROM customItemTypes WHERE customItemTypeID=?", itemTypeID - Zotero.ItemTypes.customIDOffset);
|
||||||
|
|
||||||
var searches = Zotero.Searches.getByLibrary(Zotero.Libraries.userLibraryID);
|
var searches = Zotero.Searches.getByLibrary(Zotero.Libraries.userLibraryID);
|
||||||
for (let search of searches) {
|
for (let search of searches) {
|
||||||
if (search.name == 'Overdue NSF Reviewers') {
|
if (search.name == 'Overdue NSF Reviewers') {
|
||||||
yield search.erase();
|
await search.erase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
yield _reloadSchema();
|
await _reloadSchema();
|
||||||
}.bind(this), { disableForeignKeys: true });
|
}.bind(this), { disableForeignKeys: true });
|
||||||
|
|
||||||
ps.alert(null, "Zotero Item Type Removed", "The 'NSF Reviewer' item type has been uninstalled.");
|
ps.alert(null, "Zotero Item Type Removed", "The 'NSF Reviewer' item type has been uninstalled.");
|
||||||
|
|
|
@ -301,9 +301,9 @@ Zotero.Sync.Storage.Local = {
|
||||||
}
|
}
|
||||||
// Update sync states in bulk
|
// Update sync states in bulk
|
||||||
if (changed) {
|
if (changed) {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let state in statesToSet) {
|
for (let state in statesToSet) {
|
||||||
yield this.updateSyncStates(statesToSet[state], parseInt(state));
|
await this.updateSyncStates(statesToSet[state], parseInt(state));
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
@ -1052,7 +1052,7 @@ Zotero.Sync.Storage.Local = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let i = 0; i < conflicts.length; i++) {
|
for (let i = 0; i < conflicts.length; i++) {
|
||||||
let conflict = conflicts[i];
|
let conflict = conflicts[i];
|
||||||
// TEMP
|
// TEMP
|
||||||
|
@ -1080,7 +1080,7 @@ Zotero.Sync.Storage.Local = {
|
||||||
syncState = this.SYNC_STATE_FORCE_DOWNLOAD;
|
syncState = this.SYNC_STATE_FORCE_DOWNLOAD;
|
||||||
}
|
}
|
||||||
item.attachmentSyncState = syncState;
|
item.attachmentSyncState = syncState;
|
||||||
yield item.save({ skipAll: true });
|
await item.save({ skipAll: true });
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -952,7 +952,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
toPurge,
|
toPurge,
|
||||||
Zotero.DB.MAX_BOUND_PARAMETERS - 1,
|
Zotero.DB.MAX_BOUND_PARAMETERS - 1,
|
||||||
function (chunk) {
|
function (chunk) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
var sql = "DELETE FROM storageDeleteLog WHERE libraryID=? AND key IN ("
|
var sql = "DELETE FROM storageDeleteLog WHERE libraryID=? AND key IN ("
|
||||||
+ chunk.map(() => '?').join() + ")";
|
+ chunk.map(() => '?').join() + ")";
|
||||||
return Zotero.DB.queryAsync(sql, [libraryID].concat(chunk));
|
return Zotero.DB.queryAsync(sql, [libraryID].concat(chunk));
|
||||||
|
|
|
@ -815,15 +815,15 @@ Zotero.Sync.Storage.Mode.ZFS.prototype = {
|
||||||
*/
|
*/
|
||||||
_updateItemFileInfo: Zotero.Promise.coroutine(function* (item, params) {
|
_updateItemFileInfo: Zotero.Promise.coroutine(function* (item, params) {
|
||||||
// Mark as in-sync
|
// Mark as in-sync
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
// Store file mod time and hash
|
// Store file mod time and hash
|
||||||
item.attachmentSyncedModificationTime = params.mtime;
|
item.attachmentSyncedModificationTime = params.mtime;
|
||||||
item.attachmentSyncedHash = params.md5;
|
item.attachmentSyncedHash = params.md5;
|
||||||
item.attachmentSyncState = "in_sync";
|
item.attachmentSyncState = "in_sync";
|
||||||
yield item.save({ skipAll: true });
|
await item.save({ skipAll: true });
|
||||||
|
|
||||||
// Update sync cache with new file metadata and version from server
|
// Update sync cache with new file metadata and version from server
|
||||||
var json = yield Zotero.Sync.Data.Local.getCacheObject(
|
var json = await Zotero.Sync.Data.Local.getCacheObject(
|
||||||
'item', item.libraryID, item.key, item.version
|
'item', item.libraryID, item.key, item.version
|
||||||
);
|
);
|
||||||
if (json) {
|
if (json) {
|
||||||
|
@ -831,10 +831,10 @@ Zotero.Sync.Storage.Mode.ZFS.prototype = {
|
||||||
json.data.version = params.version;
|
json.data.version = params.version;
|
||||||
json.data.mtime = params.mtime;
|
json.data.mtime = params.mtime;
|
||||||
json.data.md5 = params.md5;
|
json.data.md5 = params.md5;
|
||||||
yield Zotero.Sync.Data.Local.saveCacheObject('item', item.libraryID, json);
|
await Zotero.Sync.Data.Local.saveCacheObject('item', item.libraryID, json);
|
||||||
}
|
}
|
||||||
// Update item with new version from server
|
// Update item with new version from server
|
||||||
yield Zotero.Items.updateVersion([item.id], params.version);
|
await Zotero.Items.updateVersion([item.id], params.version);
|
||||||
|
|
||||||
// TODO: Can filename, contentType, and charset change the attachment item?
|
// TODO: Can filename, contentType, and charset change the attachment item?
|
||||||
});
|
});
|
||||||
|
@ -1001,9 +1001,9 @@ Zotero.Sync.Storage.Mode.ZFS.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (same) {
|
if (same) {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.Sync.Storage.setSyncedModificationTime(item.id, fmtime);
|
await Zotero.Sync.Storage.setSyncedModificationTime(item.id, fmtime);
|
||||||
yield Zotero.Sync.Storage.setSyncState(
|
await Zotero.Sync.Storage.setSyncState(
|
||||||
item.id, Zotero.Sync.Storage.Local.SYNC_STATE_IN_SYNC
|
item.id, Zotero.Sync.Storage.Local.SYNC_STATE_IN_SYNC
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -794,8 +794,8 @@ Zotero.Sync.Data.Engine.prototype._restoreRestoredCollectionItems = async functi
|
||||||
Zotero.debug(`Restoring ${addToCollection.length} `
|
Zotero.debug(`Restoring ${addToCollection.length} `
|
||||||
+ `${Zotero.Utilities.pluralize(addToCollection.length, ['item', 'items'])} `
|
+ `${Zotero.Utilities.pluralize(addToCollection.length, ['item', 'items'])} `
|
||||||
+ `to restored collection ${collection.libraryKey}`);
|
+ `to restored collection ${collection.libraryKey}`);
|
||||||
await Zotero.DB.executeTransaction(function* () {
|
await Zotero.DB.executeTransaction(async function () {
|
||||||
yield collection.addItems(addToCollection);
|
await collection.addItems(addToCollection);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
if (addToQueue.length) {
|
if (addToQueue.length) {
|
||||||
|
@ -927,7 +927,7 @@ Zotero.Sync.Data.Engine.prototype._downloadDeletions = Zotero.Promise.coroutine(
|
||||||
mergeData,
|
mergeData,
|
||||||
batchSize,
|
batchSize,
|
||||||
function (chunk) {
|
function (chunk) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
for (let json of chunk) {
|
for (let json of chunk) {
|
||||||
let data = json.data;
|
let data = json.data;
|
||||||
if (!data.deleted) continue;
|
if (!data.deleted) continue;
|
||||||
|
@ -937,7 +937,7 @@ Zotero.Sync.Data.Engine.prototype._downloadDeletions = Zotero.Promise.coroutine(
|
||||||
+ " didn't exist after conflict resolution");
|
+ " didn't exist after conflict resolution");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
yield obj.erase({
|
await obj.erase({
|
||||||
skipEditCheck: true
|
skipEditCheck: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -951,9 +951,9 @@ Zotero.Sync.Data.Engine.prototype._downloadDeletions = Zotero.Promise.coroutine(
|
||||||
toDelete,
|
toDelete,
|
||||||
batchSize,
|
batchSize,
|
||||||
function (chunk) {
|
function (chunk) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
for (let obj of chunk) {
|
for (let obj of chunk) {
|
||||||
yield obj.erase({
|
await obj.erase({
|
||||||
skipEditCheck: true,
|
skipEditCheck: true,
|
||||||
skipDeleteLog: true
|
skipDeleteLog: true
|
||||||
});
|
});
|
||||||
|
@ -1324,9 +1324,9 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func
|
||||||
yield Zotero.Sync.Data.Local.saveCacheObjects(
|
yield Zotero.Sync.Data.Local.saveCacheObjects(
|
||||||
objectType, this.libraryID, toCache
|
objectType, this.libraryID, toCache
|
||||||
);
|
);
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let i = 0; i < toSave.length; i++) {
|
for (let i = 0; i < toSave.length; i++) {
|
||||||
yield toSave[i].save({
|
await toSave[i].save({
|
||||||
skipSelect: true,
|
skipSelect: true,
|
||||||
skipSyncedUpdate: true,
|
skipSyncedUpdate: true,
|
||||||
// We want to minimize the times when server writes actually result in local
|
// We want to minimize the times when server writes actually result in local
|
||||||
|
@ -1338,7 +1338,7 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func
|
||||||
this.library.storageVersion = libraryVersion;
|
this.library.storageVersion = libraryVersion;
|
||||||
}
|
}
|
||||||
this.library.libraryVersion = libraryVersion;
|
this.library.libraryVersion = libraryVersion;
|
||||||
yield this.library.save();
|
await this.library.save();
|
||||||
objectsClass.updateVersion(updateVersionIDs, libraryVersion);
|
objectsClass.updateVersion(updateVersionIDs, libraryVersion);
|
||||||
objectsClass.updateSynced(updateSyncedIDs, true);
|
objectsClass.updateSynced(updateSyncedIDs, true);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
@ -1514,14 +1514,14 @@ Zotero.Sync.Data.Engine.prototype._updateGroupItemUsers = async function () {
|
||||||
|
|
||||||
|
|
||||||
Zotero.Sync.Data.Engine.prototype._getJSONForObject = function (objectType, id, options = {}) {
|
Zotero.Sync.Data.Engine.prototype._getJSONForObject = function (objectType, id, options = {}) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
var objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType);
|
var objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType);
|
||||||
var obj = objectsClass.get(id);
|
var obj = objectsClass.get(id);
|
||||||
var cacheObj = false;
|
var cacheObj = false;
|
||||||
// If the object has been synced before, get the pristine version from the cache so we can
|
// If the object has been synced before, get the pristine version from the cache so we can
|
||||||
// use PATCH mode and include only fields that have changed
|
// use PATCH mode and include only fields that have changed
|
||||||
if (obj.version) {
|
if (obj.version) {
|
||||||
cacheObj = yield Zotero.Sync.Data.Local.getCacheObject(
|
cacheObj = await Zotero.Sync.Data.Local.getCacheObject(
|
||||||
objectType, obj.libraryID, obj.key, obj.version
|
objectType, obj.libraryID, obj.key, obj.version
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1671,7 +1671,7 @@ Zotero.Sync.Data.Engine.prototype._upgradeCheck = Zotero.Promise.coroutine(funct
|
||||||
|
|
||||||
// Update versions on local objects modified remotely before last classic sync time,
|
// Update versions on local objects modified remotely before last classic sync time,
|
||||||
// to indicate that they don't need to receive remote updates
|
// to indicate that they don't need to receive remote updates
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let objectType in currentVersions) {
|
for (let objectType in currentVersions) {
|
||||||
let objectTypePlural = Zotero.DataObjectUtilities.getObjectTypePlural(objectType);
|
let objectTypePlural = Zotero.DataObjectUtilities.getObjectTypePlural(objectType);
|
||||||
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType);
|
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType);
|
||||||
|
@ -1692,17 +1692,17 @@ Zotero.Sync.Data.Engine.prototype._upgradeCheck = Zotero.Promise.coroutine(funct
|
||||||
versionObjects[version].push(id);
|
versionObjects[version].push(id);
|
||||||
}
|
}
|
||||||
for (let version in versionObjects) {
|
for (let version in versionObjects) {
|
||||||
yield objectsClass.updateVersion(versionObjects[version], version);
|
await objectsClass.updateVersion(versionObjects[version], version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark library as requiring full sync
|
// Mark library as requiring full sync
|
||||||
this.library.libraryVersion = -1;
|
this.library.libraryVersion = -1;
|
||||||
yield this.library.save();
|
await this.library.save();
|
||||||
|
|
||||||
// If this is the last classic sync library, delete old timestamps
|
// If this is the last classic sync library, delete old timestamps
|
||||||
if (!(yield Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM libraries WHERE version=0"))) {
|
if (!(await Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM libraries WHERE version=0"))) {
|
||||||
yield Zotero.DB.queryAsync(
|
await Zotero.DB.queryAsync(
|
||||||
"DELETE FROM version WHERE schema IN ('lastlocalsync', 'lastremotesync')"
|
"DELETE FROM version WHERE schema IN ('lastlocalsync', 'lastremotesync')"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1856,21 +1856,21 @@ Zotero.Sync.Data.Engine.prototype._restoreToServer = async function () {
|
||||||
// Flag engine as restore-to-server mode so it uses library version only
|
// Flag engine as restore-to-server mode so it uses library version only
|
||||||
this._restoringToServer = true;
|
this._restoringToServer = true;
|
||||||
|
|
||||||
await Zotero.DB.executeTransaction(function* () {
|
await Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.Sync.Data.Local.clearCacheForLibrary(this.libraryID);
|
await Zotero.Sync.Data.Local.clearCacheForLibrary(this.libraryID);
|
||||||
yield Zotero.Sync.Data.Local.clearQueueForLibrary(this.libraryID);
|
await Zotero.Sync.Data.Local.clearQueueForLibrary(this.libraryID);
|
||||||
yield Zotero.Sync.Data.Local.clearDeleteLogForLibrary(this.libraryID);
|
await Zotero.Sync.Data.Local.clearDeleteLogForLibrary(this.libraryID);
|
||||||
|
|
||||||
// Mark all local settings as unsynced
|
// Mark all local settings as unsynced
|
||||||
yield Zotero.SyncedSettings.markAllAsUnsynced(this.libraryID);
|
await Zotero.SyncedSettings.markAllAsUnsynced(this.libraryID);
|
||||||
|
|
||||||
// Mark all objects as unsynced
|
// Mark all objects as unsynced
|
||||||
for (let objectType of Zotero.DataObjectUtilities.getTypesForLibrary(this.libraryID)) {
|
for (let objectType of Zotero.DataObjectUtilities.getTypesForLibrary(this.libraryID)) {
|
||||||
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType);
|
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType);
|
||||||
// Reset version on all objects and mark as unsynced
|
// Reset version on all objects and mark as unsynced
|
||||||
let ids = yield objectsClass.getAllIDs(this.libraryID)
|
let ids = await objectsClass.getAllIDs(this.libraryID)
|
||||||
yield objectsClass.updateVersion(ids, 0);
|
await objectsClass.updateVersion(ids, 0);
|
||||||
yield objectsClass.updateSynced(ids, false);
|
await objectsClass.updateSynced(ids, false);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
|
|
@ -76,12 +76,12 @@ Zotero.Sync.EventListeners.ChangeListener = new function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (storageSets.length) {
|
if (storageSets.length) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.DB.queryAsync(
|
await Zotero.DB.queryAsync(
|
||||||
syncSQL + Array(syncSets.length / 3).fill('(?, ?, ?)').join(', '),
|
syncSQL + Array(syncSets.length / 3).fill('(?, ?, ?)').join(', '),
|
||||||
syncSets
|
syncSets
|
||||||
);
|
);
|
||||||
yield Zotero.DB.queryAsync(
|
await Zotero.DB.queryAsync(
|
||||||
storageSQL + Array(storageSets.length / 2).fill('(?, ?)').join(', '),
|
storageSQL + Array(storageSets.length / 2).fill('(?, ?)').join(', '),
|
||||||
storageSets
|
storageSets
|
||||||
);
|
);
|
||||||
|
|
|
@ -159,20 +159,20 @@ Zotero.Sync.Data.FullTextEngine.prototype._upload = Zotero.Promise.coroutine(fun
|
||||||
libraryVersion,
|
libraryVersion,
|
||||||
jsonArray
|
jsonArray
|
||||||
));
|
));
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let state of ['successful', 'unchanged']) {
|
for (let state of ['successful', 'unchanged']) {
|
||||||
for (let index in results[state]) {
|
for (let index in results[state]) {
|
||||||
let key = results[state][index].key;
|
let key = results[state][index].key;
|
||||||
let itemID = Zotero.Items.getIDFromLibraryAndKey(this.libraryID, key);
|
let itemID = Zotero.Items.getIDFromLibraryAndKey(this.libraryID, key);
|
||||||
yield Zotero.FullText.setItemSynced(itemID, libraryVersion);
|
await Zotero.FullText.setItemSynced(itemID, libraryVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set both the library version and the full-text library version. The latter is necessary
|
// Set both the library version and the full-text library version. The latter is necessary
|
||||||
// because full-text sync can be turned off at any time, so we have to keep track of the
|
// because full-text sync can be turned off at any time, so we have to keep track of the
|
||||||
// last version we've seen for full-text in case the main library version has advanced since.
|
// last version we've seen for full-text in case the main library version has advanced since.
|
||||||
yield Zotero.FullText.setLibraryVersion(this.libraryID, libraryVersion);
|
await Zotero.FullText.setLibraryVersion(this.libraryID, libraryVersion);
|
||||||
this.library.libraryVersion = libraryVersion;
|
this.library.libraryVersion = libraryVersion;
|
||||||
yield this.library.save();
|
await this.library.save();
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
for (let index in results.failed) {
|
for (let index in results.failed) {
|
||||||
|
|
|
@ -898,8 +898,8 @@ Zotero.Sync.Data.Local = {
|
||||||
// Errors have to be thrown in order to roll back the transaction, so catch those here
|
// Errors have to be thrown in order to roll back the transaction, so catch those here
|
||||||
// and continue
|
// and continue
|
||||||
try {
|
try {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
let obj = yield objectsClass.getByLibraryAndKeyAsync(
|
let obj = await objectsClass.getByLibraryAndKeyAsync(
|
||||||
libraryID, objectKey, { noCache: true }
|
libraryID, objectKey, { noCache: true }
|
||||||
);
|
);
|
||||||
let restored = false;
|
let restored = false;
|
||||||
|
@ -923,7 +923,7 @@ Zotero.Sync.Data.Local = {
|
||||||
Zotero.debug("Local " + objectType + " " + obj.libraryKey
|
Zotero.debug("Local " + objectType + " " + obj.libraryKey
|
||||||
+ " has been modified since last sync", 4);
|
+ " has been modified since last sync", 4);
|
||||||
|
|
||||||
let cachedJSON = yield this.getCacheObject(
|
let cachedJSON = await this.getCacheObject(
|
||||||
objectType, obj.libraryID, obj.key, obj.version
|
objectType, obj.libraryID, obj.key, obj.version
|
||||||
);
|
);
|
||||||
let result = this._reconcileChanges(
|
let result = this._reconcileChanges(
|
||||||
|
@ -947,7 +947,7 @@ Zotero.Sync.Data.Local = {
|
||||||
if (result.localChanged) {
|
if (result.localChanged) {
|
||||||
saveOptions.saveAsUnsynced = true;
|
saveOptions.saveAsUnsynced = true;
|
||||||
}
|
}
|
||||||
let saveResults = yield this._saveObjectFromJSON(
|
let saveResults = await this._saveObjectFromJSON(
|
||||||
obj,
|
obj,
|
||||||
jsonObject,
|
jsonObject,
|
||||||
saveOptions
|
saveOptions
|
||||||
|
@ -1028,7 +1028,7 @@ Zotero.Sync.Data.Local = {
|
||||||
saveOptions.isNewObject = true;
|
saveOptions.isNewObject = true;
|
||||||
|
|
||||||
// Check if object has been deleted locally
|
// Check if object has been deleted locally
|
||||||
let dateDeleted = yield this.getDateDeleted(
|
let dateDeleted = await this.getDateDeleted(
|
||||||
objectType, libraryID, objectKey
|
objectType, libraryID, objectKey
|
||||||
);
|
);
|
||||||
if (dateDeleted) {
|
if (dateDeleted) {
|
||||||
|
@ -1064,7 +1064,7 @@ Zotero.Sync.Data.Local = {
|
||||||
case 'search':
|
case 'search':
|
||||||
Zotero.debug(`${ObjectType} ${objectKey} was modified remotely `
|
Zotero.debug(`${ObjectType} ${objectKey} was modified remotely `
|
||||||
+ '-- restoring');
|
+ '-- restoring');
|
||||||
yield this.removeObjectsFromDeleteLog(
|
await this.removeObjectsFromDeleteLog(
|
||||||
objectType,
|
objectType,
|
||||||
libraryID,
|
libraryID,
|
||||||
[objectKey]
|
[objectKey]
|
||||||
|
@ -1081,13 +1081,13 @@ Zotero.Sync.Data.Local = {
|
||||||
obj = new Zotero[ObjectType];
|
obj = new Zotero[ObjectType];
|
||||||
obj.libraryID = libraryID;
|
obj.libraryID = libraryID;
|
||||||
obj.key = objectKey;
|
obj.key = objectKey;
|
||||||
yield obj.loadPrimaryData();
|
await obj.loadPrimaryData();
|
||||||
|
|
||||||
// Don't cache new items immediately, which skips reloading after save
|
// Don't cache new items immediately, which skips reloading after save
|
||||||
saveOptions.skipCache = true;
|
saveOptions.skipCache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let saveResults = yield this._saveObjectFromJSON(obj, jsonObject, saveOptions);
|
let saveResults = await this._saveObjectFromJSON(obj, jsonObject, saveOptions);
|
||||||
if (restored) {
|
if (restored) {
|
||||||
saveResults.restored = true;
|
saveResults.restored = true;
|
||||||
}
|
}
|
||||||
|
@ -1341,8 +1341,8 @@ Zotero.Sync.Data.Local = {
|
||||||
// Errors have to be thrown in order to roll back the transaction, so catch
|
// Errors have to be thrown in order to roll back the transaction, so catch
|
||||||
// those here and continue
|
// those here and continue
|
||||||
try {
|
try {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
let obj = yield objectsClass.getByLibraryAndKeyAsync(
|
let obj = await objectsClass.getByLibraryAndKeyAsync(
|
||||||
libraryID, json.key, { noCache: true }
|
libraryID, json.key, { noCache: true }
|
||||||
);
|
);
|
||||||
// Update object with merge data
|
// Update object with merge data
|
||||||
|
@ -1350,7 +1350,7 @@ Zotero.Sync.Data.Local = {
|
||||||
// Delete local object
|
// Delete local object
|
||||||
if (json.deleted) {
|
if (json.deleted) {
|
||||||
try {
|
try {
|
||||||
yield obj.erase({
|
await obj.erase({
|
||||||
notifierQueue
|
notifierQueue
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1385,14 +1385,14 @@ Zotero.Sync.Data.Local = {
|
||||||
obj = new Zotero[ObjectType];
|
obj = new Zotero[ObjectType];
|
||||||
obj.libraryID = libraryID;
|
obj.libraryID = libraryID;
|
||||||
obj.key = json.key;
|
obj.key = json.key;
|
||||||
yield obj.loadPrimaryData();
|
await obj.loadPrimaryData();
|
||||||
|
|
||||||
// Don't cache new items immediately,
|
// Don't cache new items immediately,
|
||||||
// which skips reloading after save
|
// which skips reloading after save
|
||||||
saveOptions.skipCache = true;
|
saveOptions.skipCache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let saveResults = yield this._saveObjectFromJSON(obj, json, saveOptions);
|
let saveResults = await this._saveObjectFromJSON(obj, json, saveOptions);
|
||||||
results.push(saveResults);
|
results.push(saveResults);
|
||||||
if (!saveResults.processed) {
|
if (!saveResults.processed) {
|
||||||
throw saveResults.error;
|
throw saveResults.error;
|
||||||
|
|
|
@ -1238,16 +1238,16 @@ Zotero.Sync.Runner_Module = function (options = {}) {
|
||||||
case 'split':
|
case 'split':
|
||||||
for (let libraryID of editableLibraries) {
|
for (let libraryID of editableLibraries) {
|
||||||
let itemIDs = yield Zotero.Tags.getTagItems(libraryID, oldTagID);
|
let itemIDs = yield Zotero.Tags.getTagItems(libraryID, oldTagID);
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let itemID of itemIDs) {
|
for (let itemID of itemIDs) {
|
||||||
let item = yield Zotero.Items.getAsync(itemID);
|
let item = await Zotero.Items.getAsync(itemID);
|
||||||
for (let tag of dataOut.result.tags) {
|
for (let tag of dataOut.result.tags) {
|
||||||
item.addTag(tag);
|
item.addTag(tag);
|
||||||
}
|
}
|
||||||
item.removeTag(oldTag);
|
item.removeTag(oldTag);
|
||||||
yield item.save();
|
await item.save();
|
||||||
}
|
}
|
||||||
yield Zotero.Tags.purge(oldTagID);
|
await Zotero.Tags.purge(oldTagID);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1255,11 +1255,11 @@ Zotero.Sync.Runner_Module = function (options = {}) {
|
||||||
case 'edit':
|
case 'edit':
|
||||||
for (let libraryID of editableLibraries) {
|
for (let libraryID of editableLibraries) {
|
||||||
let itemIDs = yield Zotero.Tags.getTagItems(libraryID, oldTagID);
|
let itemIDs = yield Zotero.Tags.getTagItems(libraryID, oldTagID);
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let itemID of itemIDs) {
|
for (let itemID of itemIDs) {
|
||||||
let item = yield Zotero.Items.getAsync(itemID);
|
let item = await Zotero.Items.getAsync(itemID);
|
||||||
item.replaceTag(oldTag, dataOut.result.tag);
|
item.replaceTag(oldTag, dataOut.result.tag);
|
||||||
yield item.save();
|
await item.save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,7 +407,7 @@ Zotero.Translate.ItemSaver.prototype = {
|
||||||
var parentIDs = collections.map(c => null);
|
var parentIDs = collections.map(c => null);
|
||||||
var topLevelCollections = [];
|
var topLevelCollections = [];
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
while(collectionsToProcess.length) {
|
while(collectionsToProcess.length) {
|
||||||
var collection = collectionsToProcess.shift();
|
var collection = collectionsToProcess.shift();
|
||||||
var parentID = parentIDs.shift();
|
var parentID = parentIDs.shift();
|
||||||
|
@ -422,7 +422,7 @@ Zotero.Translate.ItemSaver.prototype = {
|
||||||
newCollection.parentID = rootCollectionID;
|
newCollection.parentID = rootCollectionID;
|
||||||
topLevelCollections.push(newCollection)
|
topLevelCollections.push(newCollection)
|
||||||
}
|
}
|
||||||
yield newCollection.save(this._saveOptions);
|
await newCollection.save(this._saveOptions);
|
||||||
|
|
||||||
var toAdd = [];
|
var toAdd = [];
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ Zotero.Translate.ItemSaver.prototype = {
|
||||||
|
|
||||||
if(toAdd.length) {
|
if(toAdd.length) {
|
||||||
Zotero.debug("Translate: Adding " + toAdd, 5);
|
Zotero.debug("Translate: Adding " + toAdd, 5);
|
||||||
yield newCollection.addItems(toAdd);
|
await newCollection.addItems(toAdd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
|
@ -1675,18 +1675,18 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||||
this.purgeDataObjects = Zotero.Promise.coroutine(function* () {
|
this.purgeDataObjects = Zotero.Promise.coroutine(function* () {
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
return Zotero.Creators.purge();
|
return Zotero.Creators.purge();
|
||||||
});
|
});
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
return Zotero.Tags.purge();
|
return Zotero.Tags.purge();
|
||||||
});
|
});
|
||||||
yield Zotero.Fulltext.purgeUnusedWords();
|
yield Zotero.Fulltext.purgeUnusedWords();
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
return Zotero.Items.purge();
|
return Zotero.Items.purge();
|
||||||
});
|
});
|
||||||
// DEBUG: this might not need to be permanent
|
// DEBUG: this might not need to be permanent
|
||||||
//yield Zotero.DB.executeTransaction(function* () {
|
//yield Zotero.DB.executeTransaction(async function () {
|
||||||
// return Zotero.Relations.purge();
|
// return Zotero.Relations.purge();
|
||||||
//});
|
//});
|
||||||
|
|
||||||
|
|
|
@ -973,16 +973,16 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
|
|
||||||
let itemID;
|
let itemID;
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
var item = new Zotero.Item(typeID);
|
var item = new Zotero.Item(typeID);
|
||||||
item.libraryID = libraryID;
|
item.libraryID = libraryID;
|
||||||
for (var i in data) {
|
for (var i in data) {
|
||||||
item.setField(i, data[i]);
|
item.setField(i, data[i]);
|
||||||
}
|
}
|
||||||
itemID = yield item.save();
|
itemID = await item.save();
|
||||||
|
|
||||||
if (collectionTreeRow && collectionTreeRow.isCollection()) {
|
if (collectionTreeRow && collectionTreeRow.isCollection()) {
|
||||||
yield collectionTreeRow.ref.addItem(itemID);
|
await collectionTreeRow.ref.addItem(itemID);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1757,21 +1757,21 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
var newItem;
|
var newItem;
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
newItem = item.clone();
|
newItem = item.clone();
|
||||||
// If in a collection, add new item to it
|
// If in a collection, add new item to it
|
||||||
if (self.getCollectionTreeRow().isCollection() && newItem.isTopLevelItem()) {
|
if (self.getCollectionTreeRow().isCollection() && newItem.isTopLevelItem()) {
|
||||||
newItem.setCollections([self.getCollectionTreeRow().ref.id]);
|
newItem.setCollections([self.getCollectionTreeRow().ref.id]);
|
||||||
}
|
}
|
||||||
yield newItem.save();
|
await newItem.save();
|
||||||
if (item.isNote() && Zotero.Libraries.get(newItem.libraryID).filesEditable) {
|
if (item.isNote() && Zotero.Libraries.get(newItem.libraryID).filesEditable) {
|
||||||
yield Zotero.Notes.copyEmbeddedImages(item, newItem);
|
await Zotero.Notes.copyEmbeddedImages(item, newItem);
|
||||||
}
|
}
|
||||||
for (let relItemKey of item.relatedItems) {
|
for (let relItemKey of item.relatedItems) {
|
||||||
try {
|
try {
|
||||||
let relItem = yield Zotero.Items.getByLibraryAndKeyAsync(item.libraryID, relItemKey);
|
let relItem = await Zotero.Items.getByLibraryAndKeyAsync(item.libraryID, relItemKey);
|
||||||
if (relItem.addRelatedItem(newItem)) {
|
if (relItem.addRelatedItem(newItem)) {
|
||||||
yield relItem.save({
|
await relItem.save({
|
||||||
skipDateModifiedUpdate: true
|
skipDateModifiedUpdate: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -756,12 +756,12 @@ function generateAllTypesAndFieldsData() {
|
||||||
* The field values should be in the form exactly as they would appear in Zotero
|
* The field values should be in the form exactly as they would appear in Zotero
|
||||||
*/
|
*/
|
||||||
function populateDBWithSampleData(data) {
|
function populateDBWithSampleData(data) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(async function () {
|
||||||
for (let itemName in data) {
|
for (let itemName in data) {
|
||||||
let item = data[itemName];
|
let item = data[itemName];
|
||||||
let zItem = new Zotero.Item;
|
let zItem = new Zotero.Item;
|
||||||
zItem.fromJSON(item);
|
zItem.fromJSON(item);
|
||||||
item.id = yield zItem.save();
|
item.id = await zItem.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -363,11 +363,11 @@ describe("Zotero.CollectionTree", function() {
|
||||||
|
|
||||||
it("should add multiple collections", function* () {
|
it("should add multiple collections", function* () {
|
||||||
var col1, col2;
|
var col1, col2;
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
col1 = createUnsavedDataObject('collection');
|
col1 = createUnsavedDataObject('collection');
|
||||||
col2 = createUnsavedDataObject('collection');
|
col2 = createUnsavedDataObject('collection');
|
||||||
yield col1.save();
|
await col1.save();
|
||||||
yield col2.save();
|
await col2.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
var aRow = cv.getRowIndexByID("C" + col1.id);
|
var aRow = cv.getRowIndexByID("C" + col1.id);
|
||||||
|
|
|
@ -8,8 +8,8 @@ describe("Zotero.Creators", function() {
|
||||||
lastName: "Last"
|
lastName: "Last"
|
||||||
};
|
};
|
||||||
var creatorID;
|
var creatorID;
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
creatorID = yield Zotero.Creators.getIDFromData(data1, true);
|
creatorID = await Zotero.Creators.getIDFromData(data1, true);
|
||||||
});
|
});
|
||||||
assert.typeOf(creatorID, 'number');
|
assert.typeOf(creatorID, 'number');
|
||||||
var data2 = Zotero.Creators.get(creatorID);
|
var data2 = Zotero.Creators.get(creatorID);
|
||||||
|
|
|
@ -71,13 +71,13 @@ describe("Zotero.DataObjectUtilities", function() {
|
||||||
describe("fields", function () {
|
describe("fields", function () {
|
||||||
it("should not show empty items as different", function* () {
|
it("should not show empty items as different", function* () {
|
||||||
var id1, id2, json1, json2;
|
var id1, id2, json1, json2;
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
var item = new Zotero.Item('book');
|
var item = new Zotero.Item('book');
|
||||||
id1 = yield item.save();
|
id1 = await item.save();
|
||||||
json1 = item.toJSON();
|
json1 = item.toJSON();
|
||||||
|
|
||||||
var item = new Zotero.Item('book');
|
var item = new Zotero.Item('book');
|
||||||
id2 = yield item.save();
|
id2 = await item.save();
|
||||||
json2 = item.toJSON();
|
json2 = item.toJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@ describe("Zotero.DataObjects", function () {
|
||||||
it("should return a libraryID and key within a transaction", function* () {
|
it("should return a libraryID and key within a transaction", function* () {
|
||||||
for (let type of types) {
|
for (let type of types) {
|
||||||
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(type);
|
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(type);
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
let obj = createUnsavedDataObject(type);
|
let obj = createUnsavedDataObject(type);
|
||||||
yield obj.save();
|
await obj.save();
|
||||||
|
|
||||||
var {libraryID, key} = objectsClass.getLibraryAndKeyFromID(obj.id);
|
var {libraryID, key} = objectsClass.getLibraryAndKeyFromID(obj.id);
|
||||||
assert.equal(libraryID, Zotero.Libraries.userLibraryID);
|
assert.equal(libraryID, Zotero.Libraries.userLibraryID);
|
||||||
|
@ -32,7 +32,7 @@ describe("Zotero.DataObjects", function () {
|
||||||
assert.typeOf(key, 'string');
|
assert.typeOf(key, 'string');
|
||||||
assert.equal(key, obj.key);
|
assert.equal(key, obj.key);
|
||||||
|
|
||||||
yield obj.erase();
|
await obj.erase();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -42,9 +42,9 @@ describe("Zotero.DataObjects", function () {
|
||||||
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(type);
|
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(type);
|
||||||
var obj;
|
var obj;
|
||||||
try {
|
try {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
obj = createUnsavedDataObject(type);
|
obj = createUnsavedDataObject(type);
|
||||||
yield obj.save();
|
await obj.save();
|
||||||
throw 'Aborting transaction -- ignore';
|
throw 'Aborting transaction -- ignore';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,21 +192,21 @@ describe("Zotero.DB", function() {
|
||||||
reject2 = reject;
|
reject2 = reject;
|
||||||
});
|
});
|
||||||
|
|
||||||
Zotero.DB.executeTransaction(function* () {
|
Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.Promise.delay(250);
|
await Zotero.Promise.delay(250);
|
||||||
var num = yield Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM " + tmpTable);
|
var num = await Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM " + tmpTable);
|
||||||
assert.equal(num, 0);
|
assert.equal(num, 0);
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (1)");
|
await Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (1)");
|
||||||
assert.ok(Zotero.DB.inTransaction());
|
assert.ok(Zotero.DB.inTransaction());
|
||||||
})
|
})
|
||||||
.then(resolve1)
|
.then(resolve1)
|
||||||
.catch(reject1);
|
.catch(reject1);
|
||||||
|
|
||||||
Zotero.DB.executeTransaction(function* () {
|
Zotero.DB.executeTransaction(async function () {
|
||||||
var num = yield Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM " + tmpTable);
|
var num = await Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM " + tmpTable);
|
||||||
assert.equal(num, 1);
|
assert.equal(num, 1);
|
||||||
yield Zotero.Promise.delay(500);
|
await Zotero.Promise.delay(500);
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (2)");
|
await Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (2)");
|
||||||
assert.ok(Zotero.DB.inTransaction());
|
assert.ok(Zotero.DB.inTransaction());
|
||||||
})
|
})
|
||||||
.then(resolve2)
|
.then(resolve2)
|
||||||
|
@ -231,30 +231,30 @@ describe("Zotero.DB", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Start a transaction and have it delay
|
// Start a transaction and have it delay
|
||||||
Zotero.DB.executeTransaction(function* () {
|
Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.Promise.delay(100);
|
await Zotero.Promise.delay(100);
|
||||||
var num = yield Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM " + tmpTable);
|
var num = await Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM " + tmpTable);
|
||||||
assert.equal(num, 0);
|
assert.equal(num, 0);
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (1)");
|
await Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (1)");
|
||||||
assert.ok(Zotero.DB.inTransaction());
|
assert.ok(Zotero.DB.inTransaction());
|
||||||
})
|
})
|
||||||
.then(resolve1)
|
.then(resolve1)
|
||||||
.catch(reject1);
|
.catch(reject1);
|
||||||
|
|
||||||
// Start two more transactions, which should wait on the first
|
// Start two more transactions, which should wait on the first
|
||||||
Zotero.DB.executeTransaction(function* () {
|
Zotero.DB.executeTransaction(async function () {
|
||||||
var num = yield Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM " + tmpTable);
|
var num = await Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM " + tmpTable);
|
||||||
assert.equal(num, 1);
|
assert.equal(num, 1);
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (2)");
|
await Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (2)");
|
||||||
assert.ok(Zotero.DB.inTransaction());
|
assert.ok(Zotero.DB.inTransaction());
|
||||||
})
|
})
|
||||||
.then(resolve2)
|
.then(resolve2)
|
||||||
.catch(reject2);
|
.catch(reject2);
|
||||||
|
|
||||||
Zotero.DB.executeTransaction(function* () {
|
Zotero.DB.executeTransaction(async function () {
|
||||||
var num = yield Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM " + tmpTable);
|
var num = await Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM " + tmpTable);
|
||||||
assert.equal(num, 2);
|
assert.equal(num, 2);
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (3)");
|
await Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (3)");
|
||||||
// But make sure the second queued transaction doesn't start at the same time,
|
// But make sure the second queued transaction doesn't start at the same time,
|
||||||
// such that the first queued transaction gets closed while the second is still
|
// such that the first queued transaction gets closed while the second is still
|
||||||
// running
|
// running
|
||||||
|
@ -269,8 +269,8 @@ describe("Zotero.DB", function() {
|
||||||
it("should roll back on error", function* () {
|
it("should roll back on error", function* () {
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (1)");
|
yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (1)");
|
||||||
try {
|
try {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (2)");
|
await Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (2)");
|
||||||
throw 'Aborting transaction -- ignore';
|
throw 'Aborting transaction -- ignore';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -290,8 +290,8 @@ describe("Zotero.DB", function() {
|
||||||
var callbackRan = false;
|
var callbackRan = false;
|
||||||
try {
|
try {
|
||||||
yield Zotero.DB.executeTransaction(
|
yield Zotero.DB.executeTransaction(
|
||||||
function* () {
|
async function () {
|
||||||
yield Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (1)");
|
await Zotero.DB.queryAsync("INSERT INTO " + tmpTable + " VALUES (1)");
|
||||||
throw 'Aborting transaction -- ignore';
|
throw 'Aborting transaction -- ignore';
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -331,9 +331,9 @@ describe("Zotero.DB", function() {
|
||||||
var callback1Ran = false;
|
var callback1Ran = false;
|
||||||
var callback2Ran = false;
|
var callback2Ran = false;
|
||||||
try {
|
try {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.DB.executeTransaction(
|
await Zotero.DB.executeTransaction(
|
||||||
function* () {},
|
async function () {},
|
||||||
{
|
{
|
||||||
waitTimeout: 100,
|
waitTimeout: 100,
|
||||||
onRollback: function () {
|
onRollback: function () {
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe("Zotero.Groups", function () {
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (group) {
|
if (group) {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
return group.erase();
|
return group.erase();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,19 +139,19 @@ describe("Item pane", function () {
|
||||||
var item;
|
var item;
|
||||||
var note1;
|
var note1;
|
||||||
var note2;
|
var note2;
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
item = createUnsavedDataObject('item');
|
item = createUnsavedDataObject('item');
|
||||||
yield item.save();
|
await item.save();
|
||||||
|
|
||||||
note1 = new Zotero.Item('note');
|
note1 = new Zotero.Item('note');
|
||||||
note1.parentID = item.id;
|
note1.parentID = item.id;
|
||||||
note1.setNote('A');
|
note1.setNote('A');
|
||||||
yield note1.save();
|
await note1.save();
|
||||||
|
|
||||||
note2 = new Zotero.Item('note');
|
note2 = new Zotero.Item('note');
|
||||||
note2.parentID = item.id;
|
note2.parentID = item.id;
|
||||||
note2.setNote('B');
|
note2.setNote('B');
|
||||||
yield note2.save();
|
await note2.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
var tabs = doc.getElementById('zotero-editpane-tabs');
|
var tabs = doc.getElementById('zotero-editpane-tabs');
|
||||||
|
@ -179,19 +179,19 @@ describe("Item pane", function () {
|
||||||
var item;
|
var item;
|
||||||
var note1;
|
var note1;
|
||||||
var note2;
|
var note2;
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
item = createUnsavedDataObject('item');
|
item = createUnsavedDataObject('item');
|
||||||
yield item.save();
|
await item.save();
|
||||||
|
|
||||||
note1 = new Zotero.Item('note');
|
note1 = new Zotero.Item('note');
|
||||||
note1.parentID = item.id;
|
note1.parentID = item.id;
|
||||||
note1.setNote('A');
|
note1.setNote('A');
|
||||||
yield note1.save();
|
await note1.save();
|
||||||
|
|
||||||
note2 = new Zotero.Item('note');
|
note2 = new Zotero.Item('note');
|
||||||
note2.parentID = item.id;
|
note2.parentID = item.id;
|
||||||
note2.setNote('B');
|
note2.setNote('B');
|
||||||
yield note2.save();
|
await note2.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
var tabs = doc.getElementById('zotero-editpane-tabs');
|
var tabs = doc.getElementById('zotero-editpane-tabs');
|
||||||
|
@ -220,19 +220,19 @@ describe("Item pane", function () {
|
||||||
var item;
|
var item;
|
||||||
var note1;
|
var note1;
|
||||||
var note2;
|
var note2;
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
item = createUnsavedDataObject('item');
|
item = createUnsavedDataObject('item');
|
||||||
yield item.save();
|
await item.save();
|
||||||
|
|
||||||
note1 = new Zotero.Item('note');
|
note1 = new Zotero.Item('note');
|
||||||
note1.parentID = item.id;
|
note1.parentID = item.id;
|
||||||
note1.setNote('A');
|
note1.setNote('A');
|
||||||
yield note1.save();
|
await note1.save();
|
||||||
|
|
||||||
note2 = new Zotero.Item('note');
|
note2 = new Zotero.Item('note');
|
||||||
note2.parentID = item.id;
|
note2.parentID = item.id;
|
||||||
note2.setNote('B');
|
note2.setNote('B');
|
||||||
yield note2.save();
|
await note2.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
var tabs = doc.getElementById('zotero-editpane-tabs');
|
var tabs = doc.getElementById('zotero-editpane-tabs');
|
||||||
|
|
|
@ -2237,13 +2237,13 @@ describe("Zotero.Item", function () {
|
||||||
var item4 = yield createDataObject('item');
|
var item4 = yield createDataObject('item');
|
||||||
|
|
||||||
var relateItems = Zotero.Promise.coroutine(function* (i1, i2) {
|
var relateItems = Zotero.Promise.coroutine(function* (i1, i2) {
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
i1.addRelatedItem(i2);
|
i1.addRelatedItem(i2);
|
||||||
yield i1.save({
|
await i1.save({
|
||||||
skipDateModifiedUpdate: true
|
skipDateModifiedUpdate: true
|
||||||
});
|
});
|
||||||
i2.addRelatedItem(i1);
|
i2.addRelatedItem(i1);
|
||||||
yield i2.save({
|
await i2.save({
|
||||||
skipDateModifiedUpdate: true
|
skipDateModifiedUpdate: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -373,8 +373,8 @@ describe("Zotero.ItemTree", function() {
|
||||||
|
|
||||||
// Remove item
|
// Remove item
|
||||||
var treeRow = itemsView.getRow(2);
|
var treeRow = itemsView.getRow(2);
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield collection.removeItems([treeRow.ref.id]);
|
await collection.removeItems([treeRow.ref.id]);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
// Selection should stay on third row
|
// Selection should stay on third row
|
||||||
|
@ -414,12 +414,12 @@ describe("Zotero.ItemTree", function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var num = numVisibleRows + 10;
|
var num = numVisibleRows + 10;
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let i = 0; i < num; i++) {
|
for (let i = 0; i < num; i++) {
|
||||||
let title = getTitle(i, num);
|
let title = getTitle(i, num);
|
||||||
let item = createUnsavedDataObject('item', { title });
|
let item = createUnsavedDataObject('item', { title });
|
||||||
item.addToCollection(collection.id);
|
item.addToCollection(collection.id);
|
||||||
yield item.save();
|
await item.save();
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
@ -436,12 +436,12 @@ describe("Zotero.ItemTree", function() {
|
||||||
skipSelect: true
|
skipSelect: true
|
||||||
});
|
});
|
||||||
// Then add a few more in a transaction
|
// Then add a few more in a transaction
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
var item = createUnsavedDataObject(
|
var item = createUnsavedDataObject(
|
||||||
'item', { title: getTitle(0, num), collections: [collection.id] }
|
'item', { title: getTitle(0, num), collections: [collection.id] }
|
||||||
);
|
);
|
||||||
yield item.save({
|
await item.save({
|
||||||
skipSelect: true
|
skipSelect: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -465,12 +465,12 @@ describe("Zotero.ItemTree", function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var num = numVisibleRows + 10;
|
var num = numVisibleRows + 10;
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let i = 0; i < num; i++) {
|
for (let i = 0; i < num; i++) {
|
||||||
let title = getTitle(i, num);
|
let title = getTitle(i, num);
|
||||||
let item = createUnsavedDataObject('item', { title });
|
let item = createUnsavedDataObject('item', { title });
|
||||||
item.addToCollection(collection.id);
|
item.addToCollection(collection.id);
|
||||||
yield item.save();
|
await item.save();
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
@ -490,12 +490,12 @@ describe("Zotero.ItemTree", function() {
|
||||||
skipSelect: true
|
skipSelect: true
|
||||||
});
|
});
|
||||||
// Then add a few more in a transaction
|
// Then add a few more in a transaction
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
var item = createUnsavedDataObject(
|
var item = createUnsavedDataObject(
|
||||||
'item', { title: getTitle(0, num), collections: [collection.id] }
|
'item', { title: getTitle(0, num), collections: [collection.id] }
|
||||||
);
|
);
|
||||||
yield item.save({
|
await item.save({
|
||||||
skipSelect: true
|
skipSelect: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -521,13 +521,13 @@ describe("Zotero.ItemTree", function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var num = numVisibleRows + 10;
|
var num = numVisibleRows + 10;
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
// Start at "*1" so we can add items before
|
// Start at "*1" so we can add items before
|
||||||
for (let i = 1; i < num; i++) {
|
for (let i = 1; i < num; i++) {
|
||||||
let title = getTitle(i, num);
|
let title = getTitle(i, num);
|
||||||
let item = createUnsavedDataObject('item', { title });
|
let item = createUnsavedDataObject('item', { title });
|
||||||
item.addToCollection(collection.id);
|
item.addToCollection(collection.id);
|
||||||
yield item.save();
|
await item.save();
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
@ -542,12 +542,12 @@ describe("Zotero.ItemTree", function() {
|
||||||
skipSelect: true
|
skipSelect: true
|
||||||
});
|
});
|
||||||
// Then add a few more in a transaction
|
// Then add a few more in a transaction
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
var item = createUnsavedDataObject(
|
var item = createUnsavedDataObject(
|
||||||
'item', { title: getTitle(0, num), collections: [collection.id] }
|
'item', { title: getTitle(0, num), collections: [collection.id] }
|
||||||
);
|
);
|
||||||
yield item.save({
|
await item.save({
|
||||||
skipSelect: true
|
skipSelect: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,12 @@ describe("Zotero.Notifier", function () {
|
||||||
};
|
};
|
||||||
var id = Zotero.Notifier.registerObserver(observer, null, 'test_trigger');
|
var id = Zotero.Notifier.registerObserver(observer, null, 'test_trigger');
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
var item = new Zotero.Item('book');
|
var item = new Zotero.Item('book');
|
||||||
item.setField('title', 'A');
|
item.setField('title', 'A');
|
||||||
yield item.save();
|
await item.save();
|
||||||
item.setField('title', 'B');
|
item.setField('title', 'B');
|
||||||
yield item.save();
|
await item.save();
|
||||||
|
|
||||||
Zotero.Notifier.queue('unknown', 'item', item.id);
|
Zotero.Notifier.queue('unknown', 'item', item.id);
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,8 +37,8 @@ describe("Zotero.Relations", function () {
|
||||||
var rels = item2.getRelationsByPredicate(Zotero.Relations.relatedItemPredicate);
|
var rels = item2.getRelationsByPredicate(Zotero.Relations.relatedItemPredicate);
|
||||||
assert.include(rels[0], "/users/local");
|
assert.include(rels[0], "/users/local");
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.Relations.updateUser(null, 1);
|
await Zotero.Relations.updateUser(null, 1);
|
||||||
})
|
})
|
||||||
|
|
||||||
var rels = item2.getRelationsByPredicate(Zotero.Relations.relatedItemPredicate);
|
var rels = item2.getRelationsByPredicate(Zotero.Relations.relatedItemPredicate);
|
||||||
|
@ -56,8 +56,8 @@ describe("Zotero.Relations", function () {
|
||||||
var rels = item2.getRelationsByPredicate(Zotero.Relations.relatedItemPredicate);
|
var rels = item2.getRelationsByPredicate(Zotero.Relations.relatedItemPredicate);
|
||||||
assert.include(rels[0], "/users/1");
|
assert.include(rels[0], "/users/1");
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.Relations.updateUser(1, 2);
|
await Zotero.Relations.updateUser(1, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
var rels = item2.getRelationsByPredicate(Zotero.Relations.relatedItemPredicate);
|
var rels = item2.getRelationsByPredicate(Zotero.Relations.relatedItemPredicate);
|
||||||
|
|
|
@ -145,10 +145,10 @@ describe("Tag Selector", function () {
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
var promise = waitForTagSelector(win);
|
var promise = waitForTagSelector(win);
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield item1.save();
|
await item1.save();
|
||||||
yield item2.save();
|
await item2.save();
|
||||||
yield item3.save();
|
await item3.save();
|
||||||
});
|
});
|
||||||
yield promise;
|
yield promise;
|
||||||
|
|
||||||
|
@ -177,10 +177,10 @@ describe("Tag Selector", function () {
|
||||||
var item3 = createUnsavedDataObject('item', { collections: [collection.id] });
|
var item3 = createUnsavedDataObject('item', { collections: [collection.id] });
|
||||||
item3.setTags([tag3]);
|
item3.setTags([tag3]);
|
||||||
var promise = waitForTagSelector(win);
|
var promise = waitForTagSelector(win);
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield item1.save();
|
await item1.save();
|
||||||
yield item2.save();
|
await item2.save();
|
||||||
yield item3.save();
|
await item3.save();
|
||||||
});
|
});
|
||||||
yield promise;
|
yield promise;
|
||||||
|
|
||||||
|
|
|
@ -142,8 +142,8 @@ describe("Zotero.Tags", function () {
|
||||||
|
|
||||||
assert.equal(Zotero.Tags.getName(tagID), tagName);
|
assert.equal(Zotero.Tags.getName(tagID), tagName);
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
yield Zotero.Tags.purge();
|
await Zotero.Tags.purge();
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.isFalse(Zotero.Tags.getName(tagID));
|
assert.isFalse(Zotero.Tags.getName(tagID));
|
||||||
|
|
|
@ -1709,13 +1709,13 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
let getter = new Zotero.Translate.ItemGetter();
|
let getter = new Zotero.Translate.ItemGetter();
|
||||||
let items, itemIDs, itemURIs;
|
let items, itemIDs, itemURIs;
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
items = [
|
items = [
|
||||||
yield new Zotero.Item('journalArticle'),
|
await new Zotero.Item('journalArticle'),
|
||||||
yield new Zotero.Item('book')
|
await new Zotero.Item('book')
|
||||||
];
|
];
|
||||||
|
|
||||||
itemIDs = [ yield items[0].save(), yield items[1].save() ];
|
itemIDs = [ await items[0].save(), await items[1].save() ];
|
||||||
itemURIs = items.map(i => Zotero.URI.getItemURI(i));
|
itemURIs = items.map(i => Zotero.URI.getItemURI(i));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1729,19 +1729,19 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
let getter = new Zotero.Translate.ItemGetter();
|
let getter = new Zotero.Translate.ItemGetter();
|
||||||
let itemWithAutomaticTag, itemWithManualTag, itemWithMultipleTags
|
let itemWithAutomaticTag, itemWithManualTag, itemWithMultipleTags
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
itemWithAutomaticTag = new Zotero.Item('journalArticle');
|
itemWithAutomaticTag = new Zotero.Item('journalArticle');
|
||||||
itemWithAutomaticTag.addTag('automatic tag', 0);
|
itemWithAutomaticTag.addTag('automatic tag', 0);
|
||||||
yield itemWithAutomaticTag.save();
|
await itemWithAutomaticTag.save();
|
||||||
|
|
||||||
itemWithManualTag = new Zotero.Item('journalArticle');
|
itemWithManualTag = new Zotero.Item('journalArticle');
|
||||||
itemWithManualTag.addTag('manual tag', 1);
|
itemWithManualTag.addTag('manual tag', 1);
|
||||||
yield itemWithManualTag.save();
|
await itemWithManualTag.save();
|
||||||
|
|
||||||
itemWithMultipleTags = new Zotero.Item('journalArticle');
|
itemWithMultipleTags = new Zotero.Item('journalArticle');
|
||||||
itemWithMultipleTags.addTag('tag1', 0);
|
itemWithMultipleTags.addTag('tag1', 0);
|
||||||
itemWithMultipleTags.addTag('tag2', 1);
|
itemWithMultipleTags.addTag('tag2', 1);
|
||||||
yield itemWithMultipleTags.save();
|
await itemWithMultipleTags.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
let legacyMode = [false, true];
|
let legacyMode = [false, true];
|
||||||
|
@ -1778,14 +1778,14 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
let getter = new Zotero.Translate.ItemGetter();
|
let getter = new Zotero.Translate.ItemGetter();
|
||||||
let items, collections;
|
let items, collections;
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
items = getter._itemsLeft = [
|
items = getter._itemsLeft = [
|
||||||
new Zotero.Item('journalArticle'), // Not in collection
|
new Zotero.Item('journalArticle'), // Not in collection
|
||||||
new Zotero.Item('journalArticle'), // In a single collection
|
new Zotero.Item('journalArticle'), // In a single collection
|
||||||
new Zotero.Item('journalArticle'), //In two collections
|
new Zotero.Item('journalArticle'), //In two collections
|
||||||
new Zotero.Item('journalArticle') // In a nested collection
|
new Zotero.Item('journalArticle') // In a nested collection
|
||||||
];
|
];
|
||||||
yield Zotero.Promise.all(items.map(item => item.save()));
|
await Zotero.Promise.all(items.map(item => item.save()));
|
||||||
|
|
||||||
collections = [
|
collections = [
|
||||||
new Zotero.Collection,
|
new Zotero.Collection,
|
||||||
|
@ -1797,16 +1797,16 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
collections[1].name = "test2";
|
collections[1].name = "test2";
|
||||||
collections[2].name = "subTest1";
|
collections[2].name = "subTest1";
|
||||||
collections[3].name = "subTest2";
|
collections[3].name = "subTest2";
|
||||||
yield collections[0].save();
|
await collections[0].save();
|
||||||
yield collections[1].save();
|
await collections[1].save();
|
||||||
collections[2].parentID = collections[0].id;
|
collections[2].parentID = collections[0].id;
|
||||||
collections[3].parentID = collections[1].id;
|
collections[3].parentID = collections[1].id;
|
||||||
yield collections[2].save();
|
await collections[2].save();
|
||||||
yield collections[3].save();
|
await collections[3].save();
|
||||||
|
|
||||||
yield collections[0].addItems([items[1].id, items[2].id]);
|
await collections[0].addItems([items[1].id, items[2].id]);
|
||||||
yield collections[1].addItem(items[2].id);
|
await collections[1].addItem(items[2].id);
|
||||||
yield collections[2].addItem(items[3].id);
|
await collections[2].addItem(items[3].id);
|
||||||
});
|
});
|
||||||
|
|
||||||
let translatorItem = getter.nextItem();
|
let translatorItem = getter.nextItem();
|
||||||
|
@ -1837,7 +1837,7 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
let getter = new Zotero.Translate.ItemGetter();
|
let getter = new Zotero.Translate.ItemGetter();
|
||||||
let items;
|
let items;
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
items = [
|
items = [
|
||||||
new Zotero.Item('journalArticle'), // Item with no relations
|
new Zotero.Item('journalArticle'), // Item with no relations
|
||||||
|
|
||||||
|
@ -1848,15 +1848,15 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
new Zotero.Item('journalArticle'), // But this item is not related to the item below
|
new Zotero.Item('journalArticle'), // But this item is not related to the item below
|
||||||
new Zotero.Item('journalArticle')
|
new Zotero.Item('journalArticle')
|
||||||
];
|
];
|
||||||
yield Zotero.Promise.all(items.map(item => item.save()));
|
await Zotero.Promise.all(items.map(item => item.save()));
|
||||||
|
|
||||||
yield items[1].addRelatedItem(items[2]);
|
await items[1].addRelatedItem(items[2]);
|
||||||
yield items[2].addRelatedItem(items[1]);
|
await items[2].addRelatedItem(items[1]);
|
||||||
|
|
||||||
yield items[3].addRelatedItem(items[4]);
|
await items[3].addRelatedItem(items[4]);
|
||||||
yield items[4].addRelatedItem(items[3]);
|
await items[4].addRelatedItem(items[3]);
|
||||||
yield items[3].addRelatedItem(items[5]);
|
await items[3].addRelatedItem(items[5]);
|
||||||
yield items[5].addRelatedItem(items[3]);
|
await items[5].addRelatedItem(items[3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
getter._itemsLeft = items.slice();
|
getter._itemsLeft = items.slice();
|
||||||
|
@ -1902,24 +1902,24 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
it('should return standalone note in expected format', Zotero.Promise.coroutine(function* () {
|
it('should return standalone note in expected format', Zotero.Promise.coroutine(function* () {
|
||||||
let relatedItem, note, collection;
|
let relatedItem, note, collection;
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
relatedItem = new Zotero.Item('journalArticle');
|
relatedItem = new Zotero.Item('journalArticle');
|
||||||
yield relatedItem.save();
|
await relatedItem.save();
|
||||||
|
|
||||||
note = new Zotero.Item('note');
|
note = new Zotero.Item('note');
|
||||||
note.setNote('Note');
|
note.setNote('Note');
|
||||||
note.addTag('automaticTag', 0);
|
note.addTag('automaticTag', 0);
|
||||||
note.addTag('manualTag', 1);
|
note.addTag('manualTag', 1);
|
||||||
note.addRelatedItem(relatedItem);
|
note.addRelatedItem(relatedItem);
|
||||||
yield note.save();
|
await note.save();
|
||||||
|
|
||||||
relatedItem.addRelatedItem(note);
|
relatedItem.addRelatedItem(note);
|
||||||
yield relatedItem.save();
|
await relatedItem.save();
|
||||||
|
|
||||||
collection = new Zotero.Collection;
|
collection = new Zotero.Collection;
|
||||||
collection.name = 'test';
|
collection.name = 'test';
|
||||||
yield collection.save();
|
await collection.save();
|
||||||
yield collection.addItem(note.id);
|
await collection.addItem(note.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
let legacyMode = [false, true];
|
let legacyMode = [false, true];
|
||||||
|
@ -1985,32 +1985,32 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
}));
|
}));
|
||||||
it('should return attached note in expected format', Zotero.Promise.coroutine(function* () {
|
it('should return attached note in expected format', Zotero.Promise.coroutine(function* () {
|
||||||
let relatedItem, items, collection, note;
|
let relatedItem, items, collection, note;
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
relatedItem = new Zotero.Item('journalArticle');
|
relatedItem = new Zotero.Item('journalArticle');
|
||||||
yield relatedItem.save();
|
await relatedItem.save();
|
||||||
|
|
||||||
items = [
|
items = [
|
||||||
new Zotero.Item('journalArticle'),
|
new Zotero.Item('journalArticle'),
|
||||||
new Zotero.Item('journalArticle')
|
new Zotero.Item('journalArticle')
|
||||||
];
|
];
|
||||||
yield Zotero.Promise.all(items.map(item => item.save()));
|
await Zotero.Promise.all(items.map(item => item.save()));
|
||||||
|
|
||||||
collection = new Zotero.Collection;
|
collection = new Zotero.Collection;
|
||||||
collection.name = 'test';
|
collection.name = 'test';
|
||||||
yield collection.save();
|
await collection.save();
|
||||||
yield collection.addItem(items[0].id);
|
await collection.addItem(items[0].id);
|
||||||
yield collection.addItem(items[1].id);
|
await collection.addItem(items[1].id);
|
||||||
|
|
||||||
note = new Zotero.Item('note');
|
note = new Zotero.Item('note');
|
||||||
note.setNote('Note');
|
note.setNote('Note');
|
||||||
note.addTag('automaticTag', 0);
|
note.addTag('automaticTag', 0);
|
||||||
note.addTag('manualTag', 1);
|
note.addTag('manualTag', 1);
|
||||||
yield note.save();
|
await note.save();
|
||||||
|
|
||||||
note.addRelatedItem(relatedItem);
|
note.addRelatedItem(relatedItem);
|
||||||
relatedItem.addRelatedItem(note);
|
relatedItem.addRelatedItem(note);
|
||||||
yield note.save();
|
await note.save();
|
||||||
yield relatedItem.save();
|
await relatedItem.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
let legacyMode = [false, true];
|
let legacyMode = [false, true];
|
||||||
|
@ -2094,11 +2094,11 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
let file = getTestPDF();
|
let file = getTestPDF();
|
||||||
let item, relatedItem;
|
let item, relatedItem;
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
item = new Zotero.Item('journalArticle');
|
item = new Zotero.Item('journalArticle');
|
||||||
yield item.save();
|
await item.save();
|
||||||
relatedItem = new Zotero.Item('journalArticle');
|
relatedItem = new Zotero.Item('journalArticle');
|
||||||
yield relatedItem.save();
|
await relatedItem.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attachment items
|
// Attachment items
|
||||||
|
@ -2110,7 +2110,7 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
yield Zotero.Attachments.linkFromURL({"url":'http://example.com', "parentItemID":item.id, "contentType":'application/pdf', "title":'empty.pdf'}) // Attached link to URL
|
yield Zotero.Attachments.linkFromURL({"url":'http://example.com', "parentItemID":item.id, "contentType":'application/pdf', "title":'empty.pdf'}) // Attached link to URL
|
||||||
];
|
];
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function* () {
|
yield Zotero.DB.executeTransaction(async function () {
|
||||||
// Make sure all fields are populated
|
// Make sure all fields are populated
|
||||||
for (let i=0; i<attachments.length; i++) {
|
for (let i=0; i<attachments.length; i++) {
|
||||||
let attachment = attachments[i];
|
let attachment = attachments[i];
|
||||||
|
@ -2124,12 +2124,12 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
|
|
||||||
attachment.addRelatedItem(relatedItem);
|
attachment.addRelatedItem(relatedItem);
|
||||||
|
|
||||||
yield attachment.save();
|
await attachment.save();
|
||||||
|
|
||||||
relatedItem.addRelatedItem(attachment);
|
relatedItem.addRelatedItem(attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
yield relatedItem.save();
|
await relatedItem.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
let items = [ attachments[0], attachments[1], item ]; // Standalone attachments and item with child attachments
|
let items = [ attachments[0], attachments[1], item ]; // Standalone attachments and item with child attachments
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue