comparison rust/hg-core/src/revlog/mod.rs @ 51862:09ece563609a

rust-revlog: don't try to open the data file if the index is empty This will cover the case where the data file is not present.
author Rapha?l Gom?s <rgomes@octobus.net>
date Tue, 17 Sep 2024 10:18:32 +0200
parents 0604673428b7
children 69b804c8e09e
comparison
equal deleted inserted replaced
51861:0604673428b7 51862:09ece563609a
710 // type annotation required 710 // type annotation required
711 // won't recognize Mmap as Deref<Target = [u8]> 711 // won't recognize Mmap as Deref<Target = [u8]>
712 let data_bytes: Option<Box<dyn Deref<Target = [u8]> + Send>> = 712 let data_bytes: Option<Box<dyn Deref<Target = [u8]> + Send>> =
713 if index.is_inline() { 713 if index.is_inline() {
714 None 714 None
715 } else if index.is_empty() {
716 // No need to even try to open the data file then.
717 Some(Box::new(&[][..]))
715 } else { 718 } else {
716 let data_path = data_path.unwrap_or(&default_data_path); 719 let data_path = data_path.unwrap_or(&default_data_path);
717 let data_mmap = store_vfs.mmap_open(data_path)?; 720 let data_mmap = store_vfs.mmap_open(data_path)?;
718 Some(Box::new(data_mmap)) 721 Some(Box::new(data_mmap))
719 }; 722 };