From 79100988c1c67ef45dc3175e62cd21aa82d23cb2 Mon Sep 17 00:00:00 2001 From: Ben <36240171+benkyd@users.noreply.github.com> Date: Fri, 29 Apr 2022 19:13:27 +0100 Subject: [PATCH] asdsaad Former-commit-id: 2ce8c50f5e79263ce3cc9f3f08ce0d78893284c7 --- README.md | Bin 11440 -> 12200 bytes src/routes/cdn.js | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 48496e6b56a64117d07a824401b7954973378fec..811627c6af82f73bda19727c33af912acc43835e 100644 GIT binary patch delta 690 zcmY+CJ5K^p5QWD_MMCUsjL8}+6T#lj4hky^qluA)T@hV&kzIUL{0L%eZE3>qu<#e@ zcjm$-X2YF(=W*uD8NRMQZ@)ga=UuBTvU`iI#O7A`yKgC9j;F$wekQyM_hmN1&g>OW zsOxeY5S>|O%3I?MsTTeOj3;8kD>zjz)OZ(XW=(65l94R9)S~74_D^GeMrO8RRM?$Y z-z!Yz$i{vfIlhWgJf$5IeSnA1BeevggCB#GPM~I~OB7XWm zNWTGATBg2L(NTp2IH{q|7vGzQ8@)xmwRhPg_J0Iv8U_i7cOXo`sL+1B#TFh(5q1#y PW-9Nq@-J_8F82QbhCF@O delta 17 ZcmZ1xzaetNJeJKitS7iO#|e4K0suv?2D1PF diff --git a/src/routes/cdn.js b/src/routes/cdn.js index 86a3a00..b734199 100644 --- a/src/routes/cdn.js +++ b/src/routes/cdn.js @@ -19,12 +19,23 @@ function Get(req, res) { // TODO: bricks with a modifier should show the modified colour in the thumbnail // I HAVE NO IDEA HOW TO DO THIS WITHOUT A LOT OF WORK + // if linux + const defaultFile = `${process.cwd()}\\db\\img\\default.png`; + if (process.platform === 'linux') { + defaultFile.replace('\\', '/'); + } + // this very randomly fails sometimes try { // work out hash from id const hash = md5(id.split('.png')[0]); const bucket = hash.substring(0, 4); + + // if linux const file = `${process.cwd()}\\db\\img\\${bucket[0]}\\${bucket[1]}\\${bucket[2]}\\${bucket[3]}\\${id}`; + if (process.platform === 'linux') { + file.replace('\\', '/'); + } if (fs.existsSync(file)) { if (thumbnail) { @@ -47,7 +58,7 @@ function Get(req, res) { res.sendFile(file); } else { if (thumbnail) { - sharp(`${process.cwd()}\\db\\img\\default.png`) + sharp(defaultFile) .resize({ height: 50, }) // keep aspect ratio @@ -62,7 +73,7 @@ function Get(req, res) { }); return; } - res.sendFile(`${process.cwd()}\\db\\img\\default.png`); + res.sendFile(defaultFile); } } catch (err) { Logger.Error(err);