Fix clippy around pathbuf
This commit is contained in:
1 file changed
+16
-14
@@ -11,7 +11,6 @@ use dioxus_html::HtmlCtx;
|
|||||||
use dioxus_rsx::hot_reload::*;
|
use dioxus_rsx::hot_reload::*;
|
||||||
use interprocess_docfix::local_socket::LocalSocketListener;
|
use interprocess_docfix::local_socket::LocalSocketListener;
|
||||||
use std::{
|
use std::{
|
||||||
path::PathBuf,
|
|
||||||
process::{Child, Command},
|
process::{Child, Command},
|
||||||
sync::{Arc, Mutex, RwLock},
|
sync::{Arc, Mutex, RwLock},
|
||||||
};
|
};
|
||||||
@@ -138,19 +137,7 @@ pub async fn serve_hot_reload(config: CrateConfig) -> Result<()> {
|
|||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
clear_paths();
|
||||||
{
|
|
||||||
// On unix, if you force quit the application, it can leave the file socket open
|
|
||||||
// This will cause the local socket listener to fail to open
|
|
||||||
// We check if the file socket is already open from an old session and then delete it
|
|
||||||
let paths = ["./dioxusin", "./@dioxusin"];
|
|
||||||
for path in paths {
|
|
||||||
let path = PathBuf::from(path);
|
|
||||||
if path.exists() {
|
|
||||||
let _ = std::fs::remove_file(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
match LocalSocketListener::bind("@dioxusin") {
|
match LocalSocketListener::bind("@dioxusin") {
|
||||||
Ok(local_socket_stream) => {
|
Ok(local_socket_stream) => {
|
||||||
@@ -212,6 +199,21 @@ pub async fn serve_hot_reload(config: CrateConfig) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn clear_paths() {
|
||||||
|
if cfg!(target_os = "macos") {
|
||||||
|
// On unix, if you force quit the application, it can leave the file socket open
|
||||||
|
// This will cause the local socket listener to fail to open
|
||||||
|
// We check if the file socket is already open from an old session and then delete it
|
||||||
|
let paths = ["./dioxusin", "./@dioxusin"];
|
||||||
|
for path in paths {
|
||||||
|
let path = std::path::PathBuf::from(path);
|
||||||
|
if path.exists() {
|
||||||
|
let _ = std::fs::remove_file(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn send_msg(msg: HotReloadMsg, channel: &mut impl std::io::Write) -> bool {
|
fn send_msg(msg: HotReloadMsg, channel: &mut impl std::io::Write) -> bool {
|
||||||
if let Ok(msg) = serde_json::to_string(&msg) {
|
if let Ok(msg) = serde_json::to_string(&msg) {
|
||||||
if channel.write_all(msg.as_bytes()).is_err() {
|
if channel.write_all(msg.as_bytes()).is_err() {
|
||||||
|
|||||||
Reference in new issue
Block a user