Merge "ui/blobinfo.js: check mimeType presence to avoid exception"

This commit is contained in:
Brad Fitzpatrick 2013-06-27 15:33:00 +00:00 committed by Gerrit Code Review
commit 4bda9f3ef6
1 changed files with 18 additions and 18 deletions

View File

@ -127,25 +127,25 @@ function(bmap) {
if (binfo.camliType == "file") { if (binfo.camliType == "file") {
// TODO(mpl): we can't get the thumnails url in a describe // TODO(mpl): we can't get the thumnails url in a describe
// response because the server only gives it for a permanode. // response because the server only gives it for a permanode.
// That's why we do this messy business here. Fix it server side. // That's why we do this messy business here. Fix it server side.
try { finfo = JSON.parse(data);
finfo = JSON.parse(data); bd.innerHTML = "<a href=''></a>";
bd.innerHTML = "<a href=''></a>"; var fileName = finfo.fileName || blobref;
var fileName = finfo.fileName || blobref; bd.firstChild.href = "./download/" + blobref + "/" + fileName;
bd.firstChild.href = "./download/" + blobref + "/" + fileName; // If the mime type was not detected by magic pkg, we end up
if (binfo.file.mimeType.indexOf("image/") == 0) { // with an empty mimetype value in the indexer's fileinfo,
var thumbURL = "<img src='./thumbnail/" + blobref + "/" + // hence no mimeType in the returned JSON.
fileName + "?mw=" + this.thumbnailSize_ + if (!!binfo.file.mimeType &&
"&mh=" + this.thumbnailSize_ + "'>"; binfo.file.mimeType.indexOf("image/") == 0) {
goog.dom.getElement("thumbnail").innerHTML = thumbURL; var thumbURL = "<img src='./thumbnail/" + blobref + "/" +
} else { fileName + "?mw=" + this.thumbnailSize_ +
goog.dom.getElement("thumbnail").innerHTML = ""; "&mh=" + this.thumbnailSize_ + "'>";
} goog.dom.getElement("thumbnail").innerHTML = thumbURL;
goog.dom.setTextContent(bd.firstChild, fileName); } else {
bd.innerHTML = "download: " + bd.innerHTML; goog.dom.getElement("thumbnail").innerHTML = "";
} catch (x) {
// TOD(mpl): why?
} }
goog.dom.setTextContent(bd.firstChild, fileName);
bd.innerHTML = "download: " + bd.innerHTML;
} }
}, this), }, this),
alert alert