diff rust/hg-core/src/revlog/inner_revlog.rs @ 52294:645d247d4c75

rust-vfs: rename `open` to `open_write` and `open_read` to `open` `open` being read *and* write is surprising because it differs from the Rust stdlib where `std::fs::File::open` is read-only by default. More importantly, writing is more dangerous than reading, so let's make it more explicit.
author Rapha?l Gom?s <rgomes@octobus.net>
date Tue, 29 Oct 2024 12:03:55 +0100
parents f90796d33aa0
children 4d0c0c255425
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/inner_revlog.rs	Tue Oct 29 11:41:27 2024 +0100
+++ b/rust/hg-core/src/revlog/inner_revlog.rs	Tue Oct 29 12:03:55 2024 +0100
@@ -837,7 +837,7 @@
             self.end(Revision((self.len() - 1) as BaseRevision))
         };
         let data_handle = if !self.is_inline() {
-            let data_handle = match self.vfs.open(&self.data_file) {
+            let data_handle = match self.vfs.open_write(&self.data_file) {
                 Ok(mut f) => {
                     if let Some(end) = data_end {
                         f.seek(SeekFrom::Start(end as u64))
@@ -892,10 +892,10 @@
             if self.data_config.check_ambig {
                 self.vfs.open_check_ambig(&self.index_file)
             } else {
-                self.vfs.open(&self.index_file)
+                self.vfs.open_write(&self.index_file)
             }
         } else {
-            self.vfs.open(&self.index_file)
+            self.vfs.open_write(&self.index_file)
         };
         match res {
             Ok(mut handle) => {
@@ -1198,7 +1198,8 @@
         }
         self.vfs.copy(&self.index_file, &pending_index_file)?;
         if let Some(delayed_buffer) = self.delayed_buffer.take() {
-            let mut index_file_handle = self.vfs.open(&pending_index_file)?;
+            let mut index_file_handle =
+                self.vfs.open_write(&pending_index_file)?;
             index_file_handle
                 .seek(SeekFrom::End(0))
                 .when_writing_file(&pending_index_file)?;
@@ -1238,7 +1239,8 @@
                 ));
             }
             (Some(delay), None) => {
-                let mut index_file_handle = self.vfs.open(&self.index_file)?;
+                let mut index_file_handle =
+                    self.vfs.open_write(&self.index_file)?;
                 index_file_handle
                     .seek(SeekFrom::End(0))
                     .when_writing_file(&self.index_file)?;