Skip to content

Commit 9d94da1

Browse files
committed
feat(wrtagweb): log when cover download will be skipped
1 parent d822584 commit 9d94da1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

wrtag.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,8 @@ func copyFile(src, dest string) (err error) {
996996
return nil
997997
}
998998

999+
const maxCoverSizeBytes = 8 * 1024 * 1024 // 8 MiB
1000+
9991001
func processCover(
10001002
ctx context.Context, cfg *Config,
10011003
op FileSystemOperation, dc DirContext, release *musicbrainz.Release, destDir string, cover string,
@@ -1006,8 +1008,9 @@ func processCover(
10061008

10071009
if op.CanModifyDest() && (cover == "" || cfg.UpgradeCover) {
10081010
skipFunc := func(resp *http.Response) bool {
1009-
if resp.ContentLength > 8388608 /* 8 MiB */ {
1010-
return true // too big to download
1011+
if resp.ContentLength > maxCoverSizeBytes {
1012+
slog.WarnContext(ctx, "skipping downloading cover which is larger than max size", "size_bytes", resp.ContentLength, "max_size_bytes", maxCoverSizeBytes)
1013+
return true
10111014
}
10121015
if cover == "" {
10131016
return false

0 commit comments

Comments
 (0)