fixed cape upload

This commit is contained in:
Gilles Lazures 2026-01-18 23:32:32 +01:00
parent 0b8ab9f194
commit 086468405a

View File

@ -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)