Make attachment post-process failures non-fatal

This is generally just detecting the character set and/or indexing, so
it's not the end of the world if it fails.
This commit is contained in:
Dan Stillman 2018-06-19 18:25:53 -04:00
parent 2a7f31813e
commit 2d6332212c

View file

@ -117,8 +117,13 @@ Zotero.Attachments = new function(){
attachmentItem.attachmentPath = newFile.path; attachmentItem.attachmentPath = newFile.path;
yield attachmentItem.save(saveOptions); yield attachmentItem.save(saveOptions);
}.bind(this)); }.bind(this));
try {
yield _postProcessFile(attachmentItem, newFile, contentType); yield _postProcessFile(attachmentItem, newFile, contentType);
} }
catch (e) {
Zotero.logError(e);
}
}
catch (e) { catch (e) {
Zotero.logError(e); Zotero.logError(e);
Zotero.logError("Failed importing file " + file.path); Zotero.logError("Failed importing file " + file.path);
@ -170,7 +175,12 @@ Zotero.Attachments = new function(){
collections, collections,
saveOptions saveOptions
}); });
try {
yield _postProcessFile(item, file, contentType); yield _postProcessFile(item, file, contentType);
}
catch (e) {
Zotero.logError(e);
}
return item; return item;
}); });
@ -232,6 +242,7 @@ Zotero.Attachments = new function(){
file.parent.copyTo(storageDir, destDir.leafName); file.parent.copyTo(storageDir, destDir.leafName);
} }
}.bind(this)); }.bind(this));
try {
yield _postProcessFile( yield _postProcessFile(
attachmentItem, attachmentItem,
Zotero.File.pathToFile(newPath), Zotero.File.pathToFile(newPath),
@ -239,6 +250,10 @@ Zotero.Attachments = new function(){
charset charset
); );
} }
catch (e) {
Zotero.logError(e);
}
}
catch (e) { catch (e) {
Zotero.logError(e); Zotero.logError(e);