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) {
|
if(attachment.document) {
|
||||||
attachment.document = Zotero.Translate.DOMWrapper.unwrap(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) {
|
if(attachment.snapshot === false || !this._saveFiles) {
|
||||||
|
@ -360,7 +366,7 @@ Zotero.Translate.ItemSaver.prototype = {
|
||||||
try {
|
try {
|
||||||
Zotero.Attachments.linkFromURL(attachment.document.location.href, parentID,
|
Zotero.Attachments.linkFromURL(attachment.document.location.href, parentID,
|
||||||
(attachment.mimeType ? attachment.mimeType : attachment.document.contentType),
|
(attachment.mimeType ? attachment.mimeType : attachment.document.contentType),
|
||||||
(attachment.title ? attachment.title : attachment.document.title));
|
title);
|
||||||
attachmentCallback(attachment, 100);
|
attachmentCallback(attachment, 100);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
|
Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
|
||||||
|
@ -368,14 +374,14 @@ Zotero.Translate.ItemSaver.prototype = {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} 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);
|
Zotero.debug("Translate: Either mimeType or title is missing; attaching file will be slower", 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Zotero.Attachments.linkFromURL(attachment.url, parentID,
|
Zotero.Attachments.linkFromURL(attachment.url, parentID,
|
||||||
(attachment.mimeType ? attachment.mimeType : undefined),
|
(attachment.mimeType ? attachment.mimeType : undefined),
|
||||||
(attachment.title ? attachment.title : undefined));
|
title);
|
||||||
attachmentCallback(attachment, 100);
|
attachmentCallback(attachment, 100);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
|
Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
|
||||||
|
@ -389,7 +395,7 @@ Zotero.Translate.ItemSaver.prototype = {
|
||||||
try {
|
try {
|
||||||
attachment.linkMode = "imported_url";
|
attachment.linkMode = "imported_url";
|
||||||
Zotero.Attachments.importFromDocument(attachment.document,
|
Zotero.Attachments.importFromDocument(attachment.document,
|
||||||
parentID, attachment.title, null, function(status, err) {
|
parentID, title, null, function(status, err) {
|
||||||
if(status) {
|
if(status) {
|
||||||
attachmentCallback(attachment, 100);
|
attachmentCallback(attachment, 100);
|
||||||
} else {
|
} else {
|
||||||
|
@ -420,8 +426,6 @@ Zotero.Translate.ItemSaver.prototype = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var mimeType = (attachment.mimeType ? attachment.mimeType : null);
|
var mimeType = (attachment.mimeType ? attachment.mimeType : null);
|
||||||
var title = (attachment.title ? attachment.title : null);
|
|
||||||
|
|
||||||
var fileBaseName = Zotero.Attachments.getFileBaseNameFromItem(parentID);
|
var fileBaseName = Zotero.Attachments.getFileBaseNameFromItem(parentID);
|
||||||
try {
|
try {
|
||||||
Zotero.debug('Translate: Importing attachment from URL', 4);
|
Zotero.debug('Translate: Importing attachment from URL', 4);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user