Enable fetch to apply modifications to the database #221

Merged
wojtek merged 14 commits from 189---enable-fetch-to-apply-modifications-to-the-database into main 2024-09-29 10:44:38 +02:00
Showing only changes of commit c130519adf - Show all commits

View File

@ -27,11 +27,11 @@ macro_rules! item_option_artist_set {
meta: &ArtistMeta, meta: &ArtistMeta,
) -> Result<(), musichoard::Error> { ) -> Result<(), musichoard::Error> {
let mut info = meta.info.clone(); let mut info = meta.info.clone();
info.musicbrainz = match self { match self {
MatchOption::Some(m) => m.item.info.musicbrainz, MatchOption::Some(m) => info.musicbrainz = m.item.info.musicbrainz,
MatchOption::CannotHaveMbid => MbRefOption::CannotHaveMbid, MatchOption::CannotHaveMbid => info.musicbrainz = MbRefOption::CannotHaveMbid,
MatchOption::ManualInputMbid => panic!(), MatchOption::ManualInputMbid => panic!(),
}; }
music_hoard.set_artist_info(&meta.id, info) music_hoard.set_artist_info(&meta.id, info)
} }
} }
@ -51,15 +51,11 @@ macro_rules! item_option_album_set {
meta: &AlbumMeta, meta: &AlbumMeta,
) -> Result<(), musichoard::Error> { ) -> Result<(), musichoard::Error> {
let mut info = meta.info.clone(); let mut info = meta.info.clone();
(info.musicbrainz, info.primary_type, info.secondary_types) = match self { match self {
MatchOption::Some(m) => ( MatchOption::Some(m) => info = m.item.info,
m.item.info.musicbrainz, MatchOption::CannotHaveMbid => info.musicbrainz = MbRefOption::CannotHaveMbid,
m.item.info.primary_type,
m.item.info.secondary_types,
),
MatchOption::CannotHaveMbid => (MbRefOption::CannotHaveMbid, None, Vec::new()),
MatchOption::ManualInputMbid => panic!(), MatchOption::ManualInputMbid => panic!(),
}; }
music_hoard.set_album_info(artist, &meta.id, info) music_hoard.set_album_info(artist, &meta.id, info)
} }
} }