Fix notFound

This commit is contained in:
Bingus_Violet 2024-01-27 15:41:08 -06:00
parent 16bab47844
commit bc4b82965b

View file

@ -68,8 +68,7 @@ function get_img_url(activity) {
if (activity.name in activityImages) { if (activity.name in activityImages) {
return decodeURIComponent(activityImages[activity.name]) return decodeURIComponent(activityImages[activity.name])
} else { } else {
return '' return null
// This was supposed to be temporary but it kinda stuck honestly lol (It's an ultrakill icon)
} }
} }
} }
@ -200,15 +199,19 @@ async function pageUpdate() {
function get_img(activity) { function get_img(activity) {
var fn = sha256(get_img_url(activity)) if (get_img_url(activity)) {
var fp = path.join(staticpath, 'cached', fn) var fn = sha256(get_img_url(activity))
var fp = path.join(staticpath, 'cached', fn)
if (!fs.existsSync(fp)) {
if (!fs.existsSync(fp)) {
return 'imgs/notFound.png'
} else if (fs.statSync(fp).size < 1000) {
fs.rmSync(fp)
}
} else {
return 'imgs/notFound.png' return 'imgs/notFound.png'
} else if (fs.statSync(fp).size < 1000) {
fs.rmSync(fp)
} }
return '/cached/' + fn return '/cached/' + fn
} }
@ -402,13 +405,14 @@ lanyard.addEventListener("message", (res) => {
for (let index = 0; index < lanyardData.activities.length; index++) { for (let index = 0; index < lanyardData.activities.length; index++) {
const activity = lanyardData.activities[index]; const activity = lanyardData.activities[index];
var fn = sha256(get_img_url(activity))
var fp = path.join(__dirname, 'static/cached', fn)
if (!fs.existsSync(fp)) {
var wrst = fs.createWriteStream(fp)
if (get_img_url(activity)) { if (get_img_url(activity)) {
var fn = sha256(get_img_url(activity))
var fp = path.join(__dirname, 'static/cached', fn)
if (!fs.existsSync(fp)) {
var wrst = fs.createWriteStream(fp)
fetch(`${get_img_url(activity)}`) fetch(`${get_img_url(activity)}`)
.then((response) => response.body) .then((response) => response.body)
.then((body) => { .then((body) => {