Add "Include Annotations" checkbox to export options dialog

This changes the attachment saveFile() function in translators to be
async. In order for errors to be properly caught, translators will need
to be changed to make doExport() async and await on saveFile() calls.
(The translation architecture theoretically already allows doExport() to
be async.)
This commit is contained in:
Dan Stillman 2020-12-27 20:03:48 -05:00
parent 688298af7f
commit 55c6de23ba
8 changed files with 102 additions and 29 deletions

View file

@ -2059,7 +2059,7 @@ describe("Zotero.Translate.ItemGetter", function() {
// saveFile function
assert.isFunction(attachment.saveFile, prefix + 'has saveFile function' + suffix);
attachment.saveFile(attachment.defaultPath);
yield attachment.saveFile(attachment.defaultPath);
assert.equal(attachment.path, OS.Path.join(exportDir, OS.Path.normalize(attachment.defaultPath)), prefix + 'path is set correctly after saveFile call' + suffix);
let fileExists = yield OS.File.exists(attachment.path);
@ -2067,8 +2067,11 @@ describe("Zotero.Translate.ItemGetter", function() {
fileExists = yield OS.File.exists(attachment.localPath);
assert.isTrue(fileExists, prefix + 'file was not removed from original location' + suffix);
assert.throws(attachment.saveFile.bind(attachment, attachment.defaultPath), /^ERROR_FILE_EXISTS /, prefix + 'saveFile does not overwrite existing file by default' + suffix);
assert.throws(attachment.saveFile.bind(attachment, 'file/../../'), /./, prefix + 'saveFile does not allow exporting outside export directory' + suffix);
let e;
e = yield getPromiseError(attachment.saveFile(attachment.defaultPath));
assert.match(e.message, /^ERROR_FILE_EXISTS /, prefix + 'saveFile does not overwrite existing file by default' + suffix);
e = yield getPromiseError(attachment.saveFile('file/../../'));
assert.match(e.message, /./, prefix + 'saveFile does not allow exporting outside export directory' + suffix);
/** TODO: check if overwriting existing file works **/
}