From 6fb47651c8dd7b1c73963f6a3a6c7d95f43dc239 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 11 Nov 2022 20:27:37 +0100 Subject: [chore] Fixes + updates in emoji dereferencing logic (#1022) * fix incorrect static remote url use for emojis * warn when emoji/attachment already exists * defer emoji postdata execution * rename ctx to innerCtx for clarity * warn on emoji too large * small efficiency fix in fetchRemoteAccountEmojis * tidy up lock+load * lock processing emojis * fix little fucky wucky * this wasn't go fmted for some reason --- internal/media/processingmedia.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'internal/media/processingmedia.go') diff --git a/internal/media/processingmedia.go b/internal/media/processingmedia.go index 1247586cb..c724de849 100644 --- a/internal/media/processingmedia.go +++ b/internal/media/processingmedia.go @@ -21,6 +21,7 @@ package media import ( "bytes" "context" + "errors" "fmt" "io" "strings" @@ -349,8 +350,11 @@ func (p *ProcessingMedia) store(ctx context.Context) error { p.attachment.File.Path = fmt.Sprintf("%s/%s/%s/%s.%s", p.attachment.AccountID, TypeAttachment, SizeOriginal, p.attachment.ID, extension) // store this for now -- other processes can pull it out of storage as they please - if fileSize, err = putStream(ctx, p.storage, p.attachment.File.Path, readerToStore, fileSize); err != nil && err != storage.ErrAlreadyExists { - return fmt.Errorf("store: error storing stream: %s", err) + if fileSize, err = putStream(ctx, p.storage, p.attachment.File.Path, readerToStore, fileSize); err != nil { + if !errors.Is(err, storage.ErrAlreadyExists) { + return fmt.Errorf("store: error storing stream: %s", err) + } + log.Warnf("attachment %s already exists at storage path: %s", p.attachment.ID, p.attachment.File.Path) } cached := true -- cgit v1.2.3