Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

remote_server: Remove unnecessary Box, prevent time-of-check time-of-use bug (#24730)

tidely5d634245a2a6
diff --git a/crates/remote_server/src/unix.rs b/crates/remote_server/src/unix.rs
index 71a770908ab..88ffd1bbf63 100644
--- a/crates/remote_server/src/unix.rs
+++ b/crates/remote_server/src/unix.rs
@@ -59,7 +59,7 @@ fn init_logging_proxy() {
fn init_logging_server(log_file_path: PathBuf) -> Result<Receiver<Vec<u8>>> {
struct MultiWrite {
- file: Box<dyn std::io::Write + Send + 'static>,
+ file: std::fs::File,
channel: Sender<Vec<u8>>,
buffer: Vec<u8>,
}
@@ -80,14 +80,11 @@ fn init_logging_server(log_file_path: PathBuf) -> Result<Receiver<Vec<u8>>> {
}
}
- let log_file = Box::new(if log_file_path.exists() {
- std::fs::OpenOptions::new()
- .append(true)
- .open(&log_file_path)
- .context("Failed to open log file in append mode")?
- } else {
- std::fs::File::create(&log_file_path).context("Failed to create log file")?
- });
+ let log_file = std::fs::OpenOptions::new()
+ .create(true)
+ .append(true)
+ .open(&log_file_path)
+ .context("Failed to open log file in append mode")?;
let (tx, rx) = smol::channel::unbounded();