Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed a bug at first daemon start #3

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ pub async fn run(
socket_filename: &str,
update_interval: Duration,
) -> Result<Never, Option<String>> {
fs::remove_file(socket_filename)
if fs::try_exists(&socket_filename)
.await
.map_err(|e| format!("could not remove old socket file: {e}"))?;
.map_err(|e| format!("could not use file {socket_filename} as socket: {e}"))?
{
fs::remove_file(socket_filename)
.await
.map_err(|e| format!("could not remove old socket file: {e}"))?;
}
let listener =
UnixListener::bind(socket_filename).map_err(|e| format!("error creating socket: {e}"))?;
ready.send(()).expect("receiver should not be dropped");
Expand Down
Loading