From 0d5ce48dccf0c61f210725ffae15dafc5e9f7cab Mon Sep 17 00:00:00 2001 From: Paul Nothaft Date: Thu, 8 Jan 2026 11:44:29 +0100 Subject: [PATCH] fix: handle legacy non-JSON logo paths when replacing logo When uploading a new logo, the code tries to delete the old logo file. This failed when the old path was stored as a raw path (legacy format) instead of JSON-serialized. Added check to handle both formats. --- backend/src/routes/adminSettings.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/src/routes/adminSettings.js b/backend/src/routes/adminSettings.js index 60087f09..e655e6e3 100644 --- a/backend/src/routes/adminSettings.js +++ b/backend/src/routes/adminSettings.js @@ -326,8 +326,12 @@ router.post('/logo', adminAuth, requirePermission('settings.edit'), upload.singl .first(); if (oldLogoSetting && oldLogoSetting.setting_value) { - const oldPath = JSON.parse(oldLogoSetting.setting_value); try { + // Handle both JSON-serialized and legacy raw path values + let oldPath = oldLogoSetting.setting_value; + if (oldPath.startsWith('"')) { + oldPath = JSON.parse(oldPath); + } await fs.unlink(oldPath); } catch (error) { console.error('Failed to delete old logo:', error);