Skip to content
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

Add upgrade management logic to omit deletion of extras #10836

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

asardaes
Copy link

@asardaes asardaes commented Jan 12, 2025

Database Migration

NO

Description

This is based on the discussion in #4650 and related issues, although the changes in this PR only target upgrades. The user can decide which type of extra files shouldn't be deleted when a movie is upgraded. Since the file ID changes during an upgrade, it seems that the database needs to be updated for any extras that were not deleted, which is why ExtraFileService<TExtraFile> now implements IHandleAsync<MovieFileImportedEvent>.

I tried a few scenarios locally and it seems to work as desired. Let me know what you think.

Screenshot (if UI related)

radarr_upgrade_management

Todos

  • Tests
  • Translation Keys (./src/NzbDrone.Core/Localization/Core/en.json)
  • Wiki Updates

@github-actions github-actions bot added Area: UI Issue is related to UI, should also add the issue to the new UI project, if it isn't a bug. Area: API Issue is related to the API labels Jan 12, 2025
Also covers the case when a better movie file is placed manually in the folder,
which would be detected during a disk scan but doesn't set any old files in MovieFileImportedEvent.
Comment on lines +151 to +158
var extrasToMigrate = _repository.GetFilesByMovie(message.ImportedMovie.MovieId)
.FindAll(extra => extra.MovieFileId != message.ImportedMovie.Id)
.Select(extra =>
{
extra.MovieFileId = message.ImportedMovie.Id;
return extra;
})
.ToList();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking at this, I don't think we can merge this if we ever want multi-part support to happen. Works fine with a single file, but it won't with multiples.

Copy link
Author

Choose a reason for hiding this comment

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

Ignoring upgrades for a moment, if I understand what you're saying, it would mean that extras would have to be decoupled from movie file IDs anyway, right? They will only be linked to a movie ID regardless of how many files comprise it.

If that's the case, then I think the new logic that I implemented in this PR to handle MovieFileImportedEvent could be completely removed when multi-part support is implemented. So multi-part support would even simplify the upgrade logic.

I might be missing something since I'm not familiar with the whole code base, so correct me if I'm wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: API Issue is related to the API Area: UI Issue is related to UI, should also add the issue to the new UI project, if it isn't a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants