From 563ea5dbaaa77e59939812d6825d54cf829db8eb Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 17 Oct 2024 10:38:40 +0300 Subject: implement sizeLimit per platform --- internal/queue/queue.go | 2 +- internal/queue/sharetags.go | 4 +++- internal/queue/sharetags_test.go | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'internal/queue') diff --git a/internal/queue/queue.go b/internal/queue/queue.go index 73d5789..ddd3136 100644 --- a/internal/queue/queue.go +++ b/internal/queue/queue.go @@ -65,7 +65,7 @@ func queuePlatforms(args config.Args) error { } for filePath := range ch { - for _, platform := range args.Platforms { + for platform := range args.Platforms { if newShareTags(args, filePath).IsExcluded(platform) { log.Println("Not queueing entry", filePath, "to platform", platform, "as it is excluded") continue diff --git a/internal/queue/sharetags.go b/internal/queue/sharetags.go index 53d6306..b8088c0 100644 --- a/internal/queue/sharetags.go +++ b/internal/queue/sharetags.go @@ -32,7 +32,9 @@ func newShareTags(args config.Args, filePath string) shareTags { if len(s.includes) == 0 && len(s.excludes) == 0 { // If nothing found, include all of them - s.includes = args.Platforms + for platform := range args.Platforms { + s.includes = append(s.includes, platform) + } } return s diff --git a/internal/queue/sharetags_test.go b/internal/queue/sharetags_test.go index b2dbeec..2a2a6aa 100644 --- a/internal/queue/sharetags_test.go +++ b/internal/queue/sharetags_test.go @@ -10,10 +10,10 @@ import ( func TestShareTagsPositive(t *testing.T) { t.Parallel() - args := config.Args{Platforms: []string{"mastodon", "linkedin"}} + args := config.Args{Platforms: map[string]int{"mastodon": 100, "linkedin": 100}} testTable := map[string]shareTags{ "./foo/bar.without.tags.txt": { - includes: args.Platforms, // No tags: default platforms + includes: []string{"mastodon", "linkedin"}, }, "./foo/bar.share:linkedin.txt": { includes: []string{"linkedin"}, @@ -46,7 +46,7 @@ func TestShareTagsPositive(t *testing.T) { func TestShareTagsNegative(t *testing.T) { t.Parallel() - args := config.Args{Platforms: []string{"mastodon", "linkedin"}} + args := config.Args{Platforms: map[string]int{"mastodon": 100, "linkedin": 100}} testTable := map[string]shareTags{ "./foo/bar.without.tags.txt": { includes: []string{"linkedin"}, @@ -101,7 +101,7 @@ func TestShareTagsIsIncluded(t *testing.T) { } } } - args := config.Args{Platforms: []string{"mastodon", "linkedin"}} + args := config.Args{Platforms: map[string]int{"mastodon": 100, "linkedin": 100}} filePath := "foo/bar/baz.txt" t.Run(filePath, func(t *testing.T) { -- cgit v1.2.3