rust-revlog: don't try to open the data file if the index is empty
authorRaphaël Gomès <rgomes@octobus.net>
Tue, 17 Sep 2024 10:18:32 +0200
changeset 51866 09ece563609a
parent 51865 0604673428b7
child 51867 69b804c8e09e
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.
rust/hg-core/src/revlog/mod.rs
--- a/rust/hg-core/src/revlog/mod.rs	Wed Jun 19 12:25:12 2024 +0200
+++ b/rust/hg-core/src/revlog/mod.rs	Tue Sep 17 10:18:32 2024 +0200
@@ -712,6 +712,9 @@
         let data_bytes: Option<Box<dyn Deref<Target = [u8]> + Send>> =
             if index.is_inline() {
                 None
+            } else if index.is_empty() {
+                // No need to even try to open the data file then.
+                Some(Box::new(&[][..]))
             } else {
                 let data_path = data_path.unwrap_or(&default_data_path);
                 let data_mmap = store_vfs.mmap_open(data_path)?;