Skip to content

fix(stremio): persist NzbTTLHours of 0 across API round-trip - #803

Merged
javi11 merged 1 commit into
mainfrom
session/nzb-cleanup-persistence-1a881c
Jul 25, 2026
Merged

fix(stremio): persist NzbTTLHours of 0 across API round-trip#803
javi11 merged 1 commit into
mainfrom
session/nzb-cleanup-persistence-1a881c

Conversation

@javi11

@javi11 javi11 commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

Setting the Stremio NZB cleanup TTL to 0 ("cache forever / never expire") reverted to 24 after a page reload.

The value was persisted to disk correctly — the bug was on read-back. StremioAPIResponse.NzbTTLHours carried json:"nzb_ttl_hours,omitempty", so Go's omitempty dropped the field from GET /api/config whenever the TTL was 0. The frontend then applied config.stremio?.nzb_ttl_hours ?? 24, displaying 24 — and re-sent 24 on the next save, permanently overwriting the user's 0. Display bug → silent data loss.

Fix

Since 0 is a meaningful value ("disable expiry"), removed omitempty from:

  • StremioAPIResponse.NzbTTLHours (internal/api/types.go) — the actual bug.
  • The StremioConfig.NzbTTLHours struct field (internal/config/manager.go) — same latent bug on any future JSON marshal of Config.

This mirrors the segment-cache expiry fix in #800 (0 = cache forever).

Test

Added internal/api/stremio_ttl_test.go asserting nzb_ttl_hours:0 survives the response round-trip.

Test plan

  • go build ./...
  • go test ./internal/api/ ./internal/config/
  • Manual: set Stremio NZB TTL to 0, save, reload — value stays 0

The Stremio NZB cleanup TTL reverted from 0 to 24 after reload. The value
saved to disk correctly, but StremioAPIResponse.NzbTTLHours carried
`json:"nzb_ttl_hours,omitempty"`, so Go dropped the field from GET /api/config
whenever the TTL was 0. The frontend then applied `?? 24`, displaying 24 and
re-saving it, permanently overwriting the user's choice.

Since 0 is a meaningful value ("cache forever / disable expiry"), remove
omitempty from the API response field and from the config struct field
(same latent bug on any JSON marshal). Mirrors the segment-cache fix in #800.
@javi11
javi11 merged commit 3a14200 into main Jul 25, 2026
2 checks passed
@javi11
javi11 deleted the session/nzb-cleanup-persistence-1a881c branch July 25, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant