summaryrefslogtreecommitdiff
path: root/internal/media/refetch.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-05-28 13:08:35 +0100
committerLibravatar GitHub <noreply@github.com>2023-05-28 14:08:35 +0200
commit5faeb4de2032e112ab49751eeeb906ac43826f3d (patch)
treeea94b86f27384954ff93aec864b13b83c7f46db0 /internal/media/refetch.go
parent[docs] Update + simplify roadmap, revise beta estimate (#1826) (diff)
downloadgotosocial-5faeb4de2032e112ab49751eeeb906ac43826f3d.tar.xz
[chore] tidy up media manager, add calling func to errors, build-script improvements (#1835)
* media manager tidy-up: de-interface and remove unused PostDataFunc Signed-off-by: kim <grufwub@gmail.com> * remove last traces of media.Manager being an interface Signed-off-by: kim <grufwub@gmail.com> * update error to provide caller, allow tuneable via build tags Signed-off-by: kim <grufwub@gmail.com> * remove kim-specific build script changes Signed-off-by: kim <grufwub@gmail.com> * fix merge conflicts Signed-off-by: kim <grufwub@gmail.com> * update build-script to support externally setting build variables Signed-off-by: kim <grufwub@gmail.com> --------- Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/media/refetch.go')
-rw-r--r--internal/media/refetch.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/media/refetch.go b/internal/media/refetch.go
index 8fb08f88b..80dfe4f60 100644
--- a/internal/media/refetch.go
+++ b/internal/media/refetch.go
@@ -32,7 +32,13 @@ import (
type DereferenceMedia func(ctx context.Context, iri *url.URL) (io.ReadCloser, int64, error)
-func (m *manager) RefetchEmojis(ctx context.Context, domain string, dereferenceMedia DereferenceMedia) (int, error) {
+// RefetchEmojis iterates through remote emojis (for the given domain, or all if domain is empty string).
+//
+// For each emoji, the manager will check whether both the full size and static images are present in storage.
+// If not, the manager will refetch and reprocess full size and static images for the emoji.
+//
+// The provided DereferenceMedia function will be used when it's necessary to refetch something this way.
+func (m *Manager) RefetchEmojis(ctx context.Context, domain string, dereferenceMedia DereferenceMedia) (int, error) {
// normalize domain
if domain == "" {
domain = db.EmojiAllDomains
@@ -107,7 +113,7 @@ func (m *manager) RefetchEmojis(ctx context.Context, domain string, dereferenceM
return dereferenceMedia(ctx, emojiImageIRI)
}
- processingEmoji, err := m.PreProcessEmoji(ctx, dataFunc, nil, emoji.Shortcode, emoji.ID, emoji.URI, &AdditionalEmojiInfo{
+ processingEmoji, err := m.PreProcessEmoji(ctx, dataFunc, emoji.Shortcode, emoji.ID, emoji.URI, &AdditionalEmojiInfo{
Domain: &emoji.Domain,
ImageRemoteURL: &emoji.ImageRemoteURL,
ImageStaticRemoteURL: &emoji.ImageStaticRemoteURL,
@@ -131,7 +137,7 @@ func (m *manager) RefetchEmojis(ctx context.Context, domain string, dereferenceM
return totalRefetched, nil
}
-func (m *manager) emojiRequiresRefetch(ctx context.Context, emoji *gtsmodel.Emoji) (bool, error) {
+func (m *Manager) emojiRequiresRefetch(ctx context.Context, emoji *gtsmodel.Emoji) (bool, error) {
if has, err := m.state.Storage.Has(ctx, emoji.ImagePath); err != nil {
return false, err
} else if !has {