diff --git a/README.md b/README.md index 48496e6..811627c 100644 Binary files a/README.md and b/README.md differ 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);