diff --git a/server/endpoints/system.js b/server/endpoints/system.js index 6d985065c259172c3958ead0c26ab3eee59f4c9c..39b77a6a10b63e743e5705b11384e29c07a46f12 100644 --- a/server/endpoints/system.js +++ b/server/endpoints/system.js @@ -502,7 +502,8 @@ function systemEndpoints(app) { } const userRecord = await User.get({ id: user.id }); - const oldPfpFilename = userRecord.pfpFilename; + const oldPfpFilename = normalizePath(userRecord.pfpFilename); + console.log("oldPfpFilename", oldPfpFilename); if (oldPfpFilename) { const oldPfpPath = path.join( @@ -536,7 +537,7 @@ function systemEndpoints(app) { try { const user = await userFromSession(request, response); const userRecord = await User.get({ id: user.id }); - const oldPfpFilename = userRecord.pfpFilename; + const oldPfpFilename = normalizePath(userRecord.pfpFilename); console.log("oldPfpFilename", oldPfpFilename); if (oldPfpFilename) { const oldPfpPath = path.join( diff --git a/server/utils/files/pfp.js b/server/utils/files/pfp.js index 943aa595f0e8864b9ff4eec3caec2a402da45f09..dd6ba0fe2d1c47ef4558d8e6066294bbfc751c8a 100644 --- a/server/utils/files/pfp.js +++ b/server/utils/files/pfp.js @@ -2,6 +2,7 @@ const path = require("path"); const fs = require("fs"); const { getType } = require("mime"); const { User } = require("../../models/user"); +const { normalizePath } = require("."); function fetchPfp(pfpPath) { if (!fs.existsSync(pfpPath)) { @@ -32,8 +33,7 @@ async function determinePfpFilepath(id) { const basePath = process.env.STORAGE_DIR ? path.join(process.env.STORAGE_DIR, "assets/pfp") : path.join(__dirname, "../../storage/assets/pfp"); - const pfpFilepath = path.join(basePath, pfpFilename); - + const pfpFilepath = path.join(basePath, normalizePath(pfpFilename)); if (!fs.existsSync(pfpFilepath)) return null; return pfpFilepath; }