Skip to content

Commit

Permalink
Fix: Windows Manganis Asset Hot Reload (#3330)
Browse files Browse the repository at this point in the history
* fix: windows asset hot reload

* revision: canonicalize err handling
  • Loading branch information
DogeDark authored Dec 11, 2024
1 parent 38cb275 commit b20c8ac
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/cli/src/serve/handle.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{AppBundle, Platform, Result};
use anyhow::Context;
use std::{
fs,
net::SocketAddr,
path::{Path, PathBuf},
process::Stdio,
Expand Down Expand Up @@ -187,8 +188,13 @@ impl AppHandle {
}
}

// Canonicalize the path as Windows may use long-form paths "\\\\?\\C:\\".
let changed_file = fs::canonicalize(changed_file)
.inspect_err(|e| tracing::debug!("Failed to canonicalize hotreloaded asset: {e}"))
.ok()?;

// The asset might've been renamed thanks to the manifest, let's attempt to reload that too
if let Some(resource) = self.app.app.assets.assets.get(changed_file).as_ref() {
if let Some(resource) = self.app.app.assets.assets.get(&changed_file).as_ref() {
let res = std::fs::copy(changed_file, asset_dir.join(resource.bundled_path()));
bundled_name = Some(PathBuf::from(resource.bundled_path()));
if let Err(e) = res {
Expand Down

0 comments on commit b20c8ac

Please sign in to comment.