Ensure consistency between in-memory and database state #146
@ -81,8 +81,11 @@ impl<LIB, DB> MusicHoard<LIB, DB> {
|
||||
primary.insert(secondary_artist.id.clone(), secondary_artist);
|
||||
}
|
||||
}
|
||||
|
||||
self.collection = primary.into_values().collect();
|
||||
Self::sort_artists(&mut self.collection);
|
||||
|
||||
self.pre_commit = self.collection.clone();
|
||||
}
|
||||
|
||||
fn items_to_artists(items: Vec<Item>) -> Result<HashMap<ArtistId, Artist>, Error> {
|
||||
@ -176,7 +179,7 @@ impl<LIB, DB> MusicHoard<LIB, DB> {
|
||||
}
|
||||
|
||||
impl<LIB: ILibrary> MusicHoard<LIB, NoDatabase> {
|
||||
/// Create a new [`MusicHoard`] with the provided [`IDatabase`].
|
||||
/// Create a new [`MusicHoard`] with the provided [`ILibrary`] and no database.
|
||||
pub fn library(library: LIB) -> Self {
|
||||
MusicHoard {
|
||||
collection: vec![],
|
||||
@ -202,7 +205,7 @@ impl<LIB: ILibrary, DB> MusicHoard<LIB, DB> {
|
||||
}
|
||||
|
||||
impl<DB: IDatabase> MusicHoard<NoLibrary, DB> {
|
||||
/// Create a new [`MusicHoard`] with the provided [`IDatabase`].
|
||||
/// Create a new [`MusicHoard`] with the provided [`IDatabase`] and no library.
|
||||
pub fn database(database: DB) -> Result<Self, Error> {
|
||||
let mut mh = MusicHoard {
|
||||
collection: vec![],
|
||||
@ -224,8 +227,6 @@ impl<LIB, DB: IDatabase> MusicHoard<LIB, DB> {
|
||||
Self::sort_albums_and_tracks(self.database_cache.iter_mut());
|
||||
|
||||
self.merge_collections();
|
||||
self.pre_commit = self.collection.clone();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user