Fix export failure on missing file attachments
This relies on synchronous file access, but making it async would require rewriting all export translators that save files.
This commit is contained in:
parent
44e48700ef
commit
341d3d69b3
3 changed files with 38 additions and 8 deletions
|
@ -595,6 +595,31 @@ describe("Zotero.Translate", function() {
|
|||
Zotero.Translators.get.restore();
|
||||
});
|
||||
});
|
||||
|
||||
describe("ItemSaver", function () {
|
||||
describe("#saveItems()", function () {
|
||||
it("should handle missing attachment files", function* () {
|
||||
var item = yield importFileAttachment('test.png');
|
||||
var path = item.getFilePath();
|
||||
// Delete attachment file
|
||||
yield OS.File.remove(path);
|
||||
|
||||
var translation = new Zotero.Translate.Export();
|
||||
var tmpDir = yield getTempDirectory();
|
||||
var exportDir = OS.Path.join(tmpDir, 'export');
|
||||
translation.setLocation(Zotero.File.pathToFile(exportDir));
|
||||
translation.setItems([item]);
|
||||
translation.setTranslator('14763d24-8ba0-45df-8f52-b8d1108e7ac9'); // Zotero RDF
|
||||
translation.setDisplayOptions({
|
||||
exportFileData: true
|
||||
});
|
||||
yield translation.translate();
|
||||
|
||||
var exportFile = OS.Path.join(exportDir, 'export.rdf');
|
||||
assert.isAbove((yield OS.File.stat(exportFile)).size, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Zotero.Translate.ItemGetter", function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue