FANNG1 commented on code in PR #5878:
URL: https://github.com/apache/gravitino/pull/5878#discussion_r1891063401


##########
clients/filesystem-fuse/src/filesystem.rs:
##########
@@ -201,6 +246,86 @@ pub(crate) struct OpenedFile {
     pub writer: Option<Box<dyn FileWriter>>,
 }
 
+impl OpenedFile {
+    pub fn new(file_stat: FileStat) -> Self {
+        OpenedFile {
+            file_stat: file_stat,
+            handle_id: 0,
+            reader: None,
+            writer: None,
+        }
+    }
+
+    async fn read(&mut self, offset: u64, size: u32) -> Result<Bytes> {
+        let reader = self.reader.as_mut().ok_or(Errno::from(libc::EBADF))?;
+        let result = reader.read(offset, size).await?;
+
+        // update the atime
+        self.file_stat.atime = Timestamp::from(SystemTime::now());
+
+        Ok(result)
+    }
+
+    async fn write(&mut self, offset: u64, data: &[u8]) -> Result<u32> {
+        let writer = self.writer.as_mut().ok_or(Errno::from(libc::EBADF))?;
+        let written = writer.write(offset, data).await?;

Review Comment:
   seems a bug here, if written is less than data.len()
   ```rust
           let end = offset + data.len() as u64;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to