mirror of https://github.com/perkeep/perkeep.git
Merge "ui/blobinfo.js: check mimeType presence to avoid exception"
This commit is contained in:
commit
4bda9f3ef6
|
@ -128,12 +128,15 @@ function(bmap) {
|
|||
// TODO(mpl): we can't get the thumnails url in a describe
|
||||
// response because the server only gives it for a permanode.
|
||||
// That's why we do this messy business here. Fix it server side.
|
||||
try {
|
||||
finfo = JSON.parse(data);
|
||||
bd.innerHTML = "<a href=''></a>";
|
||||
var fileName = finfo.fileName || blobref;
|
||||
bd.firstChild.href = "./download/" + blobref + "/" + fileName;
|
||||
if (binfo.file.mimeType.indexOf("image/") == 0) {
|
||||
// If the mime type was not detected by magic pkg, we end up
|
||||
// with an empty mimetype value in the indexer's fileinfo,
|
||||
// hence no mimeType in the returned JSON.
|
||||
if (!!binfo.file.mimeType &&
|
||||
binfo.file.mimeType.indexOf("image/") == 0) {
|
||||
var thumbURL = "<img src='./thumbnail/" + blobref + "/" +
|
||||
fileName + "?mw=" + this.thumbnailSize_ +
|
||||
"&mh=" + this.thumbnailSize_ + "'>";
|
||||
|
@ -143,9 +146,6 @@ function(bmap) {
|
|||
}
|
||||
goog.dom.setTextContent(bd.firstChild, fileName);
|
||||
bd.innerHTML = "download: " + bd.innerHTML;
|
||||
} catch (x) {
|
||||
// TOD(mpl): why?
|
||||
}
|
||||
}
|
||||
}, this),
|
||||
alert
|
||||
|
|
Loading…
Reference in New Issue