MCPcopy Create free account
hub / github.com/Moosync/Moosync / merge_extra_info

Method merge_extra_info

src-tauri/database/src/database.rs:994–1017  ·  view source on GitHub ↗
(
        &self,
        old_info: Option<EntityInfo>,
        new_info: Option<EntityInfo>,
    )

Source from the content-addressed store, hash-verified

992
993 #[tracing::instrument(level = "debug", skip(self, old_info, new_info))]
994 fn merge_extra_info(
995 &self,
996 old_info: Option<EntityInfo>,
997 new_info: Option<EntityInfo>,
998 ) -> Option<EntityInfo> {
999 if old_info.is_none() && new_info.is_none() {
1000 return None;
1001 }
1002
1003 if old_info.is_none() {
1004 return new_info;
1005 }
1006
1007 if new_info.is_none() {
1008 return old_info;
1009 }
1010
1011 let mut res = old_info.clone().unwrap();
1012 let mut a: Value = serde_json::from_str(res.0.as_str()).unwrap();
1013 let b: Value = serde_json::from_str(new_info.unwrap().0.as_str()).unwrap();
1014 merge(&mut a, b);
1015 res.0 = serde_json::to_string(&a).unwrap();
1016 Some(res)
1017 }
1018
1019 #[tracing::instrument(level = "debug", skip(self))]
1020 pub fn update_album(&self, mut album: QueryableAlbum) -> Result<()> {

Callers 2

update_albumMethod · 0.80
update_artistMethod · 0.80

Calls 2

mergeFunction · 0.85
cloneMethod · 0.80

Tested by

no test coverage detected