Fix library items not being deletes after providers have removed them#3154
Fix library items not being deletes after providers have removed them#3154MarvinSchenkel wants to merge 5 commits intodevfrom
Conversation
| if provider and isinstance(provider, MusicProvider) and provider.is_streaming_provider: | ||
| extra_entries.append(CONF_ENTRY_LIBRARY_SYNC_DELETIONS) |
There was a problem hiding this comment.
| if provider and isinstance(provider, MusicProvider) and provider.is_streaming_provider: | |
| extra_entries.append(CONF_ENTRY_LIBRARY_SYNC_DELETIONS) | |
| if provider and isinstance(provider, MusicProvider) and provider.is_streaming_provider: | |
| extra_entries.append(CONF_ENTRY_LIBRARY_SYNC_DELETIONS) |
I think you also need that edit check from above ?
There was a problem hiding this comment.
Why? The former is to sync back additions in MA > Streaming provider. The new toggle prevents deletions in the streaming provider from flowing back into MA.
I think this behaviour does not depend on a music provider supporting writing back library changes from MA > the Streaming provider?
So:
- Music provider does not support
LIBRARY_EDIT_XX - User disables sync back deletions
- User adds Album X in MA
- User adds Album X in music provider
- User removes Album X in music provider
- User syncs the music provider -> Should not delete Album X in MA
| ctrl = self.get_controller(media_type) | ||
| library_id = media_item.item_id if media_item.provider == "library" else None | ||
|
|
||
| # cache in_library state before the provider fetch overwrites media_item |
There was a problem hiding this comment.
can you walk me through why this is needed ?
There was a problem hiding this comment.
Without it, when you refresh an item, provider mapping's in library status is not maintained. It re-adds them with in_library = None causing them to disappear from the overview pages. This logic basically restores the original statuses after a refresh.
| for prov_map in library_item.provider_mappings: | ||
| if prov_map.provider_instance == self.instance_id: | ||
| prov_map.in_library = False | ||
| await controller.set_provider_mappings( |
There was a problem hiding this comment.
Now, within set_provider_mappings we can do an additional check (which we may already do, I'm not sure): If the item has no mappings anymore AND it is not referenced in any of the link tables (e.g. track artists etc) we can safely clean it up from db
There was a problem hiding this comment.
Do we already delete those records from the link tables? Because otherwise this check will never be True if we keep for example track_artist records for tracks without any in_library provider mappings?
There was a problem hiding this comment.
there is already some logic to handle that yeah
Co-authored-by: Marcel van der Veldt <m.vanderveldt@outlook.com>
…ave in library = False
This PR:
in_library = Trueto avoid losing items in the overview pages