Fetching and then instantly reloading library loses data #256

Merged
wojtek merged 6 commits from 254---fetching-and-then-instantly-reloading-library-loses-data into main 2025-01-05 11:06:05 +01:00
Showing only changes of commit 1bcd1ba1e1 - Show all commits

View File

@ -70,18 +70,18 @@ impl<Database, Library> IMusicHoardBasePrivate for MusicHoard<Database, Library>
} }
fn merge_collections<It: IntoIterator<Item = Artist>>(&self, database: It) -> Collection { fn merge_collections<It: IntoIterator<Item = Artist>>(&self, database: It) -> Collection {
let mut primary_map = NormalMap::<Artist>::new(); let mut primary = NormalMap::<Artist>::new();
let mut secondary_map = NormalMap::<Artist>::new(); let mut secondary = NormalMap::<Artist>::new();
for artist in self.library_cache.iter().cloned() { for artist in self.library_cache.iter().cloned() {
primary_map.insert(string::normalize_string(&artist.meta.id.name), artist); primary.insert(string::normalize_string(&artist.meta.id.name), artist);
} }
for artist in database.into_iter() { for artist in database.into_iter() {
secondary_map.insert(string::normalize_string(&artist.meta.id.name), artist); secondary.insert(string::normalize_string(&artist.meta.id.name), artist);
} }
let mut collection = MergeCollections::merge_by_name(primary_map, secondary_map); let mut collection = MergeCollections::merge_by_name(primary, secondary);
collection.sort_unstable(); collection.sort_unstable();
collection collection