MCPcopy Create free account
hub / github.com/Freaky/Compactor / load

Method load

hashfilter/src/lib.rs:32–59  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

30 }
31
32 pub fn load(&mut self) -> io::Result<()> {
33 if self.path.is_none() {
34 return Ok(());
35 }
36
37 let mut file = match File::open(self.path.as_ref().unwrap()) {
38 Ok(file) => file,
39 Err(ref e) if e.kind() == io::ErrorKind::NotFound => return Ok(()),
40 Err(e) => return Err(e),
41 };
42 file.lock_shared()?;
43
44 if self.last_offset > 0 {
45 file.seek(SeekFrom::Start(self.last_offset))?;
46 }
47
48 let mut file = BufReader::new(file);
49 let mut buf = [0; 16];
50 loop {
51 match file.read_exact(&mut buf) {
52 Ok(()) => self.filter.insert(u128::from_le_bytes(buf)),
53 Err(ref e) if e.kind() == io::ErrorKind::UnexpectedEof => return Ok(()),
54 Err(e) => return Err(e),
55 };
56
57 self.last_offset += 16;
58 }
59 }
60
61 pub fn save(&mut self) -> io::Result<()> {
62 if self.path.is_none() || self.pending.is_empty() {

Callers 6

runMethod · 0.80
spawn_guiFunction · 0.80
is_cancelledMethod · 0.80
is_pausedMethod · 0.80
compress_loopMethod · 0.80
it_seems_to_workFunction · 0.80

Calls 1

insertMethod · 0.80

Tested by 1

it_seems_to_workFunction · 0.64