Skip to content

Commit

Permalink
if socket exists remove it
Browse files Browse the repository at this point in the history
  • Loading branch information
VasilisManol committed Jan 27, 2025
1 parent ca0e0d6 commit 5ac72e7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/net/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5ac72e7

Please sign in to comment.