Repository: Canop/broot (language: rust)

Issue:
Add a way to start a server instance with an existing instance name / socket
I am using the --listen function of broot together with zellij as an IDE together with helix. Closing the zellij session leaves the socket file behind. This has the side effect that a new server instance of broot with the same name can't be started:
```
➜~ br --listen br_server
Can't open socket: /tmp/broot-server-br_server.sock already exists - consider removing it
```

It would be convenient to have a flag for forcefully delete the sock file in case there is already there, e.g.
` br --listen br_server --force`


Discussion / hints:

Fix patch:
diff --git a/src/net/server.rs b/src/net/server.rs
index e0a24df3..3b497b0c 100644
--- a/src/net/server.rs
+++ b/src/net/server.rs
@@ -27,7 +27,10 @@ impl Server {
     ) -> Result<Self, NetError> {
         let path = super::socket_file_path(name);
         if fs::metadata(&path).is_ok() {
-            return Err(NetError::SocketNotAvailable { path });
+            match fs::remove_file(&path) {
+                Ok(_) => {}
+                Err(e) => return Err(NetError::Io { source: e }),
+            }
         }
         let listener = UnixListener::bind(&path)?;
         info!("listening on {}", &path);


Test patch: