Don't show "undefined" in attachment progress window
This commit is contained in:
parent
b2a7050dea
commit
ebd8dfeb65
|
@ -351,6 +351,12 @@ Zotero.Translate.ItemSaver.prototype = {
|
|||
|
||||
if(attachment.document) {
|
||||
attachment.document = Zotero.Translate.DOMWrapper.unwrap(attachment.document);
|
||||
if(!attachment.title) attachment.title = attachment.document.title;
|
||||
}
|
||||
var title = attachment.title || null;
|
||||
if(!title) {
|
||||
// If no title provided, use "Attachment" as title for progress UI (but not for item)
|
||||
attachment.title = Zotero.getString("itemTypes.attachment");
|
||||
}
|
||||
|
||||
if(attachment.snapshot === false || !this._saveFiles) {
|
||||
|
@ -360,7 +366,7 @@ Zotero.Translate.ItemSaver.prototype = {
|
|||
try {
|
||||
Zotero.Attachments.linkFromURL(attachment.document.location.href, parentID,
|
||||
(attachment.mimeType ? attachment.mimeType : attachment.document.contentType),
|
||||
(attachment.title ? attachment.title : attachment.document.title));
|
||||
title);
|
||||
attachmentCallback(attachment, 100);
|
||||
} catch(e) {
|
||||
Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
|
||||
|
@ -368,14 +374,14 @@ Zotero.Translate.ItemSaver.prototype = {
|
|||
}
|
||||
return true;
|
||||
} else {
|
||||
if(!attachment.mimeType || !attachment.title) {
|
||||
if(!attachment.mimeType || !title) {
|
||||
Zotero.debug("Translate: Either mimeType or title is missing; attaching file will be slower", 3);
|
||||
}
|
||||
|
||||
try {
|
||||
Zotero.Attachments.linkFromURL(attachment.url, parentID,
|
||||
(attachment.mimeType ? attachment.mimeType : undefined),
|
||||
(attachment.title ? attachment.title : undefined));
|
||||
title);
|
||||
attachmentCallback(attachment, 100);
|
||||
} catch(e) {
|
||||
Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
|
||||
|
@ -389,7 +395,7 @@ Zotero.Translate.ItemSaver.prototype = {
|
|||
try {
|
||||
attachment.linkMode = "imported_url";
|
||||
Zotero.Attachments.importFromDocument(attachment.document,
|
||||
parentID, attachment.title, null, function(status, err) {
|
||||
parentID, title, null, function(status, err) {
|
||||
if(status) {
|
||||
attachmentCallback(attachment, 100);
|
||||
} else {
|
||||
|
@ -420,8 +426,6 @@ Zotero.Translate.ItemSaver.prototype = {
|
|||
return;
|
||||
}
|
||||
var mimeType = (attachment.mimeType ? attachment.mimeType : null);
|
||||
var title = (attachment.title ? attachment.title : null);
|
||||
|
||||
var fileBaseName = Zotero.Attachments.getFileBaseNameFromItem(parentID);
|
||||
try {
|
||||
Zotero.debug('Translate: Importing attachment from URL', 4);
|
||||
|
|
Loading…
Reference in New Issue
Block a user