重新获取favicon
This commit is contained in:
parent
50386b40fc
commit
79c24a146e
|
|
@ -925,18 +925,19 @@ api.getSnapFaviconByTimer = function() {
|
|||
}
|
||||
});
|
||||
|
||||
// 获取favicon
|
||||
fs.exists(faviconPath, function(exists) {
|
||||
if (exists) {
|
||||
if (faviconState != -1) {
|
||||
db.updateBookmarkFaviconState(id, -1);
|
||||
}
|
||||
} else {
|
||||
if (!/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/.test(url)) {
|
||||
fs.exists(faviconPath, function(exists) {
|
||||
if (!exists) {
|
||||
var sourceFile = './public/images/favicon/default.ico';
|
||||
var readStream = fs.createReadStream(sourceFile);
|
||||
var writeStream = fs.createWriteStream(faviconPath);
|
||||
readStream.pipe(writeStream);
|
||||
}
|
||||
});
|
||||
db.updateBookmarkFaviconState(id, today + 31);
|
||||
return;
|
||||
}
|
||||
favicon(url, function(err, faviconUrl) {
|
||||
var faviconUrl = "http://g.soz.im/"+ url +"/cdn.ico"
|
||||
if (faviconUrl) {
|
||||
download(faviconUrl, faviconPath, function(err) {
|
||||
var newFaviconState = -1;
|
||||
|
|
@ -953,9 +954,38 @@ api.getSnapFaviconByTimer = function() {
|
|||
} else {
|
||||
db.updateBookmarkFaviconState(id, today + 31);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 获取favicon(由于获取不到有些图标,暂时放弃)
|
||||
// fs.exists(faviconPath, function(exists) {
|
||||
// if (exists) {
|
||||
// if (faviconState != -1) {
|
||||
// db.updateBookmarkFaviconState(id, -1);
|
||||
// }
|
||||
// } else {
|
||||
// if (!/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/.test(url)) {
|
||||
// db.updateBookmarkFaviconState(id, today + 31);
|
||||
// return;
|
||||
// }
|
||||
// favicon(url, function(err, faviconUrl) {
|
||||
// if (faviconUrl) {
|
||||
// download(faviconUrl, faviconPath, function(err) {
|
||||
// var newFaviconState = -1;
|
||||
// if (err) {
|
||||
// console.log("boomarkid = " + id + ", download over", err)
|
||||
// if (faviconState == 0 || faviconState == 1) {
|
||||
// newFaviconState = faviconState + 1;
|
||||
// } else if (faviconState == 2) {
|
||||
// newFaviconState = today + 31;
|
||||
// }
|
||||
// }
|
||||
// db.updateBookmarkFaviconState(id, newFaviconState);
|
||||
// });
|
||||
// } else {
|
||||
// db.updateBookmarkFaviconState(id, today + 31);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
}
|
||||
})
|
||||
.catch((err) => console.log('getBookmarkWaitSnap err', err));
|
||||
|
|
|
|||
Loading…
Reference in New Issue