From 7e77e2c7e7903fe54d0111eded5ae38174faee6e Mon Sep 17 00:00:00 2001 From: learner97 Date: Sun, 1 Feb 2026 19:23:22 -0700 Subject: [PATCH] fixed an issue where logo would not appear on sbh2 --- java/.classpath | 2 ++ lib/views/logo.js | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/java/.classpath b/java/.classpath index 4d0e78c33..6ae6616f4 100644 --- a/java/.classpath +++ b/java/.classpath @@ -9,6 +9,7 @@ + @@ -22,6 +23,7 @@ + diff --git a/lib/views/logo.js b/lib/views/logo.js index e4998c8f3..7d5f0c23b 100644 --- a/lib/views/logo.js +++ b/lib/views/logo.js @@ -1,10 +1,34 @@ const config = require('../config') const path = require('path') +const fs = require('fs') function get (req, res) { + // Prefer logoFilename (full absolute path) if available + let logoFilename = config.get('logoFilename') + + if (logoFilename && fs.existsSync(logoFilename)) { + // Use the absolute path directly + return res.sendFile(logoFilename) + } + + // Fall back to instanceLogo (relative path) + let instanceLogo = config.get('instanceLogo') + if (!instanceLogo) { + return res.status(404).send('Logo not found') + } + + // Remove leading slash if present, as res.sendFile with root option expects relative path + let relativePath = instanceLogo.startsWith('/') ? instanceLogo.substring(1) : instanceLogo var dir = path.resolve(__dirname, '../../uploads') - let logoFilename = config.get('instanceLogo') - res.sendFile(logoFilename, { root: dir }) + let fullPath = path.join(dir, relativePath) + + // Check if file exists + if (!fs.existsSync(fullPath)) { + return res.status(404).send('Logo not found') + } + + // Send the file using root option + res.sendFile(relativePath, { root: dir }) } module.exports = get