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)