Skip to content

Commit 7eb321d

Browse files
committed
Fix: file watcher receives a path, not a URL, from the translator.
1 parent d580215 commit 7eb321d

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

server/src/ide/filewatcher.rs

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use crate::{
5858
queue_send,
5959
webserver::{
6060
INITIAL_IDE_MESSAGE_ID, MESSAGE_ID_INCREMENT, ResultOkTypes, WebAppState,
61-
filesystem_endpoint, get_test_mode, url_to_path,
61+
filesystem_endpoint, get_test_mode,
6262
},
6363
};
6464
use crate::{
@@ -604,34 +604,30 @@ async fn processing_task(
604604
send_response(&from_ide_tx, m.id, result).await;
605605
}
606606

607-
EditorMessageContents::CurrentFile(url_string, _is_text) => {
608-
let result = match url_to_path(&url_string, FILEWATCHER_PATH_PREFIX) {
609-
Err(err) => Err(err),
610-
Ok(ref file_path) => 'err_exit: {
611-
// We finally have the desired path! First,
612-
// unwatch the old path.
613-
if let Some(cfp) = &current_filepath
614-
&& let Err(err) = debounced_watcher.unwatch(cfp)
615-
{
616-
break 'err_exit Err(format!(
617-
"Unable to unwatch file '{}': {err}.",
618-
cfp.to_string_lossy()
619-
));
620-
}
621-
// Update to the new path.
622-
current_filepath = Some(file_path.to_path_buf());
623-
624-
// Watch the new file.
625-
if let Err(err) = debounced_watcher.watch(file_path, RecursiveMode::NonRecursive) {
626-
break 'err_exit Err(format!(
627-
"Unable to watch file '{}': {err}.",
628-
file_path.to_string_lossy()
629-
));
630-
}
631-
// Indicate there was no error in the
632-
// `Result` message.
633-
Ok(ResultOkTypes::Void)
607+
EditorMessageContents::CurrentFile(file_path_str, _is_text) => {
608+
let file_path = PathBuf::from(file_path_str.clone());
609+
let result = 'err_exit: {
610+
// Unwatch the old path.
611+
if let Some(cfp) = &current_filepath
612+
&& let Err(err) = debounced_watcher.unwatch(cfp)
613+
{
614+
break 'err_exit Err(format!(
615+
"Unable to unwatch file '{}': {err}.",
616+
cfp.to_string_lossy()
617+
));
634618
}
619+
// Update to the new path.
620+
current_filepath = Some(file_path.to_path_buf());
621+
622+
// Watch the new file.
623+
if let Err(err) = debounced_watcher.watch(file_path, RecursiveMode::NonRecursive) {
624+
break 'err_exit Err(format!(
625+
"Unable to watch file '{file_path_str}': {err}.",
626+
));
627+
}
628+
// Indicate there was no error in the `Result`
629+
// message.
630+
Ok(ResultOkTypes::Void)
635631
};
636632
send_response(&from_ide_tx, m.id, result).await;
637633
},

0 commit comments

Comments
 (0)