changeset 51866: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
files rust/hg-core/src/revlog/mod.rs
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)?;