Skip to content

Commit 84286ee

Browse files
committed
Allow flushing FileSystem without unmounting.
1 parent 7f4aa0c commit 84286ee

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/fs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,11 +597,11 @@ impl<IO: Read + Write + Seek, TP, OCC> FileSystem<IO, TP, OCC> {
597597
/// # Errors
598598
///
599599
/// `Error::Io` will be returned if the underlying storage object returned an I/O error.
600-
pub fn unmount(self) -> Result<(), Error<IO::Error>> {
601-
self.unmount_internal()
600+
pub fn unmount(mut self) -> Result<(), Error<IO::Error>> {
601+
self.flush()
602602
}
603603

604-
fn unmount_internal(&self) -> Result<(), Error<IO::Error>> {
604+
pub fn flush(&mut self) -> Result<(), Error<IO::Error>> {
605605
self.flush_fs_info()?;
606606
self.set_dirty_flag(false)?;
607607
Ok(())
@@ -705,7 +705,7 @@ impl<IO: ReadWriteSeek, TP: TimeProvider, OCC: OemCpConverter> FileSystem<IO, TP
705705
/// `Drop` implementation tries to unmount the filesystem when dropping.
706706
impl<IO: ReadWriteSeek, TP, OCC> Drop for FileSystem<IO, TP, OCC> {
707707
fn drop(&mut self) {
708-
if let Err(err) = self.unmount_internal() {
708+
if let Err(err) = self.flush() {
709709
error!("unmount failed {:?}", err);
710710
}
711711
}

0 commit comments

Comments
 (0)