fixed cape upload
This commit is contained in:
parent
0b8ab9f194
commit
086468405a
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user