From c71f03dceee5986d56f6fb47b86997904021be36 Mon Sep 17 00:00:00 2001 From: localhost Date: Sun, 16 Nov 2025 11:04:38 +0100 Subject: [PATCH] support reuploading channel avatars --- src/utils/upload.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/upload.ts b/src/utils/upload.ts index 0fe5ec5..cf183d9 100644 --- a/src/utils/upload.ts +++ b/src/utils/upload.ts @@ -25,13 +25,14 @@ async function uploadVideo(video: string) { } async function uploadImage(id: string, url: string) { - const exists = await images3.fileExists(`${id}.webp`) - if (exists) return `${keys.images[0].url}${id}.webp` - const response = await fetch(url) const buffer = Buffer.from(await response.arrayBuffer()) + const bufferHash = Bun.hash(buffer).toString() - const uploaded = await images3.put(`${id}.webp`, buffer) + const exists = await images3.fileExists(`${id}-${bufferHash}.webp`) + if (exists) return `${keys.images[0].url}${id}-${bufferHash}.webp` + + const uploaded = await images3.put(`${id}-${bufferHash}.webp`, buffer) return uploaded.url.replace(keys.endpoint, 'https://s4.archive.party') }