Skip to content

fix: ensure all wanted episodes are monitored #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 9, 2025

Conversation

jon4hz
Copy link

@jon4hz jon4hz commented Aug 6, 2025

Hi,

This PR ensures that all episodes within a season are monitored, before starting the season search.

Otherwise sonarr wont actually download missing episodes, if a season itself is monitored but not all episodes within that season.

@p-hueber p-hueber changed the base branch from latest to main August 6, 2025 23:34
src/sonarr.rs Outdated
if !season_episodes.is_empty() {
self.monitor_episodes(&season_episodes).await?;
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make it conditional? as far as I understand, it is only ever necessary if season.monitored was true.

or alternatively, replace the block above with something like

// Make sure to toggle the season so all episodes are monitored
if season.monitored {
    season.monitored = false;
    self.put_series(&series).await?;
}
season.monitored = true;
series.monitored = true;
self.put_series(&series).await?;

I'm okay with both.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! The episodes are now only monitored explicitly if the season was already monitored.

@p-hueber
Copy link
Owner

p-hueber commented Aug 7, 2025

ty for your contribution! good catch

@jon4hz
Copy link
Author

jon4hz commented Aug 7, 2025

@p-hueber would you mind lending me hand with the failing tests? I can't seem to get them working. I added a mock for the episode monitor but it's now failing with:

thread 'process::test::pilot' panicked at /home/jonah/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/httpmock-0.7.0/src/api/mock.rs:207:13:
assertion `left == right` failed: The number of matching requests was higher than expected (expected 1 but was 2)

I honestly have no idea how to fix this :(

@p-hueber
Copy link
Owner

p-hueber commented Aug 7, 2025

@p-hueber would you mind lending me hand with the failing tests?

sure! you are facing problems because the existing mocks are expected to be called exactly once. but after your change, it gets the episodes twice. adding another mock does not help, because the pattern of the first one still matches.
instead, change the expected number of hits like this:

episodes_mock.assert_hits_async(2).await;

you can check what's getting hit with RUST_LOG=httpmock=debug cargo test pilot -- --nocapture

@jon4hz
Copy link
Author

jon4hz commented Aug 8, 2025

Thank you! That did the trick :D

@p-hueber p-hueber merged commit a6d7f66 into p-hueber:main Aug 9, 2025
2 checks passed
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.

2 participants