From 31294f7c789244919ef594901c63ba703b1dfd68 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Mon, 22 Jul 2024 18:45:48 +0100 Subject: [bugfix] media.Processor{}.GetFile() returning 404s on first call, correctly loading on 2nd (#3129) * refactor file handling a tiny bit * whoops * make processing media / emoji defers a bit clear to see that it's the "on finished processing" path * some wording * add some debug logging * add mutex locks for processing remote media * try removing freshness check * fix derefMedia not being allocated * fix log format string * handle case of empty file paths (i.e. not stored) * remove media / emoji once finished processing from dereferencer maps * whoops, fix the cached / force checks * move url parsing outside of 'process___Safely()' funcs to prevalidate url * use emoji.ShortcodeDomain() * update RefreshEmoji() to also match RefreshMedia() changes --------- Co-authored-by: tobi --- internal/storage/storage.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'internal/storage/storage.go') diff --git a/internal/storage/storage.go b/internal/storage/storage.go index 508433c1a..5d5baf283 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -52,6 +52,12 @@ type PresignedURL struct { Expiry time.Time // link expires at this time } +// IsInvalidKey returns whether error is an invalid-key +// type error returned by the underlying storage library. +func IsInvalidKey(err error) bool { + return errors.Is(err, storage.ErrInvalidKey) +} + // IsAlreadyExist returns whether error is an already-exists // type error returned by the underlying storage library. func IsAlreadyExist(err error) bool { -- cgit v1.2.3