move hot reload socket into the target directory

This commit is contained in:
Evan Almloff committed 2023-12-07 07:00:59 -06:00
1 parent b965fc23e9
commit 9a13df2c73
3 files changed
+22 -20

No files matched your search

+6 -8
View File
@@ -152,22 +152,20 @@ pub fn init<Ctx: HotReloadingContext + Send + 'static>(cfg: Config<Ctx>) {
}
let file_map = Arc::new(Mutex::new(file_map));
let target_dir = crate_dir.join("target");
let hot_reload_socket_path = target_dir.join("dioxusin");
#[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"];
for path in paths {
let path = std::env::temp_dir().join(path);
if path.exists() {
let _ = std::fs::remove_file(path);
}
if hot_reload_socket_path.exists() {
let _ = std::fs::remove_file(hot_reload_socket_path);
}
}
let path = std::env::temp_dir().join("dioxusin");
match LocalSocketListener::bind(path) {
match LocalSocketListener::bind(hot_reload_socket_path) {
Ok(local_socket_stream) => {
let aborted = Arc::new(Mutex::new(false));
+5 -2
View File
@@ -1,4 +1,7 @@
use std::io::{BufRead, BufReader};
use std::{
io::{BufRead, BufReader},
path::PathBuf,
};
use dioxus_core::Template;
#[cfg(feature = "file_watcher")]
@@ -24,7 +27,7 @@ pub enum HotReloadMsg {
/// Connect to the hot reloading listener. The callback provided will be called every time a template change is detected
pub fn connect(mut f: impl FnMut(HotReloadMsg) + Send + 'static) {
std::thread::spawn(move || {
let path = std::env::temp_dir().join("dioxusin");
let path = PathBuf::from("./").join("target").join("dioxusin");
if let Ok(socket) = LocalSocketStream::connect(path) {
let mut buf_reader = BufReader::new(socket);
loop {