From 086468405a2b873683db118d0d5f28bab4f29dbb Mon Sep 17 00:00:00 2001 From: azures04 Date: Sun, 18 Jan 2026 23:32:32 +0100 Subject: [PATCH] fixed cape upload --- services/adminService.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/adminService.js b/services/adminService.js index b999665..90144dc 100644 --- a/services/adminService.js +++ b/services/adminService.js @@ -129,7 +129,14 @@ async function uploadCape(fileObject, alias = null) { const hash = crypto.createHash("sha256").update(buffer).digest("hex") const existing = await userRepository.getTextureByHash(hash) - if (existing) throw new DefaultError(409, "Cape already existing.") + if (existing) { + await fs.unlink(fileObject.path); + throw new DefaultError(409, "Cape already existing.") + } + + const finalPath = path.join(process.cwd(), "data/textures", `${hash}.png`) + + await fs.rename(fileObject.path, finalPath) const textureUrl = `/texture/${hash}` await userRepository.createTexture(crypto.randomUUID(), hash, "CAPE", textureUrl, alias)