fix(stremio): persist NzbTTLHours of 0 across API round-trip - #803
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Setting the Stremio NZB cleanup TTL to
0("cache forever / never expire") reverted to24after a page reload.The value was persisted to disk correctly — the bug was on read-back.
StremioAPIResponse.NzbTTLHourscarriedjson:"nzb_ttl_hours,omitempty", so Go'somitemptydropped the field fromGET /api/configwhenever the TTL was0. The frontend then appliedconfig.stremio?.nzb_ttl_hours ?? 24, displaying24— and re-sent24on the next save, permanently overwriting the user's0. Display bug → silent data loss.Fix
Since
0is a meaningful value ("disable expiry"), removedomitemptyfrom:StremioAPIResponse.NzbTTLHours(internal/api/types.go) — the actual bug.StremioConfig.NzbTTLHoursstruct field (internal/config/manager.go) — same latent bug on any future JSON marshal ofConfig.This mirrors the segment-cache expiry fix in #800 (0 = cache forever).
Test
Added
internal/api/stremio_ttl_test.goassertingnzb_ttl_hours:0survives the response round-trip.Test plan
go build ./...go test ./internal/api/ ./internal/config/