MCPcopy Index your code
hub / github.com/Firstyear/opensuse-proxy-cache / update_userdata

Method update_userdata

arc-disk-cache/src/lib.rs:682–722  ·  view source on GitHub ↗

Given key, update the ud.

(&self, q: &Q, mut func: F)

Source from the content-addressed store, hash-verified

680
681 // Given key, update the ud.
682 pub fn update_userdata<Q, F>(&self, q: &Q, mut func: F)
683 where
684 K: Borrow<Q>,
685 Q: Hash + Eq + Ord + ?Sized,
686 F: FnMut(&mut D),
687 {
688 let mut wrtxn = self.cache.write_stats(TraceStat::default());
689
690 if let Some(mref) = wrtxn.get_mut(q, false) {
691 func(&mut mref.userdata);
692
693 let objmeta = CacheObjMeta {
694 key: mref.key.clone(),
695 path: mref.fhandle.path.clone(),
696 crc: mref.fhandle.crc,
697 userdata: mref.userdata.clone(),
698 };
699
700 // This will truncate the metadata if it does exist.
701 let m_file = File::create(&mref.fhandle.meta_path)
702 .map(BufWriter::new)
703 .map_err(|e| {
704 error!("Failed to open metadata {:?}", e);
705 })
706 .unwrap();
707
708 serde_json::to_writer(m_file, &objmeta)
709 .map_err(|e| {
710 error!("Failed to write metadata {:?}", e);
711 })
712 .unwrap();
713
714 info!("Persisted metadata for {:?}", &mref.fhandle.meta_path);
715 }
716
717 debug!("commit");
718 let stats = wrtxn.commit();
719 let mut stat_guard = self.stats.write();
720 (*stat_guard).update(stats);
721 stat_guard.commit();
722 }
723
724 pub fn update_all_userdata<F, C>(&self, check: C, mut func: F)
725 where

Callers 1

cache_mgrFunction · 0.80

Calls 1

updateMethod · 0.80

Tested by

no test coverage detected