gerbera / gerbera

UPnP Media Server for 2024: Stream your digital media through your home network and consume it on all kinds of UPnP supporting devices 📱💻📺
https://gerbera.io
Other
1.21k stars 212 forks source link

Appears virtual folders are not purged if over >1000 Items are removed at once #547

Open whyman opened 4 years ago

whyman commented 4 years ago

Hello @whyman, thanks for a quick fix. Unfortunately fix had ripple effect uncovering another issue.

I built and installed gerbera from master, it shows me version 1.4.0alpha. With this version I executed the following test:

<<snip>>

My idea why virtual folders were not purged:

My music library has more than 1000 items including containers. Note that MAX_REMOVE_SIZE is defined to 1000. When I removed top container from PC Directory, method SQLStorage::_recursiveRemove went down the tree to items. Items were planned for scan (itemIds vector), but before that, SQLStorage::_removeObjects was called for all containers and items. As FKs are active, ON DELETE CASCADE removes all records referencing containers and items by parent_id or ref_id. It means, all lists of virtual folder structure were removed before scan of itemIds vector. Once itemIds vector scan is executed all virtual list items are gone so virtual containers are not marked as changed.

Originally posted by @pcerny in https://github.com/gerbera/gerbera/issues/487#issuecomment-517987052

whyman commented 4 years ago

Quick note to say I've replicated this locally.

All the file nodes get removed, but the folder structure remains.