summaryrefslogtreecommitdiff
path: root/internal/federation/dereferencing/dereferencer.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-07-22 18:45:48 +0100
committerLibravatar GitHub <noreply@github.com>2024-07-22 18:45:48 +0100
commit31294f7c789244919ef594901c63ba703b1dfd68 (patch)
tree10a836b0be781c5ee3dc368b33ad348b88c80858 /internal/federation/dereferencing/dereferencer.go
parent[chore]: Bump github.com/minio/minio-go/v7 from 7.0.73 to 7.0.74 (#3125) (diff)
downloadgotosocial-31294f7c789244919ef594901c63ba703b1dfd68.tar.xz
[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 <tobi.smethurst@protonmail.com>
Diffstat (limited to 'internal/federation/dereferencing/dereferencer.go')
-rw-r--r--internal/federation/dereferencing/dereferencer.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/internal/federation/dereferencing/dereferencer.go b/internal/federation/dereferencing/dereferencer.go
index f7f4d975e..bcc145c27 100644
--- a/internal/federation/dereferencing/dereferencer.go
+++ b/internal/federation/dereferencing/dereferencer.go
@@ -85,12 +85,9 @@ type Dereferencer struct {
mediaManager *media.Manager
visibility *visibility.Filter
- // in-progress dereferencing emoji. we already perform
- // locks per-status and per-account so we don't need
- // processing maps for other media which won't often
- // end up being repeated. worst case we run into an
- // db.ErrAlreadyExists error which then gets handled
- // appropriately by enrich{Account,Status}Safely().
+ // in-progress dereferencing media / emoji
+ derefMedia map[string]*media.ProcessingMedia
+ derefMediaMu sync.Mutex
derefEmojis map[string]*media.ProcessingEmoji
derefEmojisMu sync.Mutex
@@ -119,6 +116,7 @@ func NewDereferencer(
transportController: transportController,
mediaManager: mediaManager,
visibility: visFilter,
+ derefMedia: make(map[string]*media.ProcessingMedia),
derefEmojis: make(map[string]*media.ProcessingEmoji),
handshakes: make(map[string][]*url.URL),
}