From d31a97811b94fa4403939c289eaf98eaca237b0e Mon Sep 17 00:00:00 2001
From: Ben Bridle <ben@derelict.engineering>
Date: Thu, 31 Oct 2024 17:44:28 +1300
Subject: Suppress errors when flushing file and stream data

File and stream data is flushed on drop, and if flushing fails a panic
is thrown, which prints a crash message to the terminal. Since we can't
do anything if the write fails, and because file and stream writes are
approached with a best-effort attitude, we suppress the errors to
prevent the user from seeing them and getting concerned.
---
 src/devices/file_device.rs               | 2 +-
 src/devices/file_device/buffered_file.rs | 2 +-
 src/devices/local_device.rs              | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/devices')

diff --git a/src/devices/file_device.rs b/src/devices/file_device.rs
index 4859053..2d923b4 100644
--- a/src/devices/file_device.rs
+++ b/src/devices/file_device.rs
@@ -272,7 +272,7 @@ impl FileDevice {
 
     pub fn flush(&mut self) {
         if let Some((Entry::File(buffered_file), _)) = &mut self.entry {
-            buffered_file.flush();
+            let _ = buffered_file;
         }
     }
 }
diff --git a/src/devices/file_device/buffered_file.rs b/src/devices/file_device/buffered_file.rs
index 3487d54..f965950 100644
--- a/src/devices/file_device/buffered_file.rs
+++ b/src/devices/file_device/buffered_file.rs
@@ -112,7 +112,7 @@ impl BufferedFile {
 
     pub fn flush(&mut self) {
         if let AccessMode::Write(writer) = &mut self.file {
-            writer.flush().unwrap();
+            let _ = writer.flush();
         }
     }
 }
diff --git a/src/devices/local_device.rs b/src/devices/local_device.rs
index fa19de7..c6456de 100644
--- a/src/devices/local_device.rs
+++ b/src/devices/local_device.rs
@@ -162,7 +162,7 @@ impl LocalDevice {
     }
 
     pub fn flush(&mut self) {
-        self.stdout.flush().unwrap();
+       let _ = self.stdout.flush();
     }
 }
 
-- 
cgit v1.2.3-70-g09d2