mirror of https://github.com/rwf2/Rocket.git
Log I/O error when live template reloading fails.
This commit is contained in:
parent
f6325798b1
commit
e0973d95f1
|
@ -50,19 +50,19 @@ mod context {
|
|||
impl ContextManager {
|
||||
crate fn new(ctxt: Context) -> ContextManager {
|
||||
let (tx, rx) = channel();
|
||||
let watcher = raw_watcher(tx).and_then(|mut watcher| {
|
||||
watcher.watch(ctxt.root.canonicalize()?, RecursiveMode::Recursive)?;
|
||||
Ok(watcher)
|
||||
});
|
||||
|
||||
let watcher = if let Ok(mut watcher) = raw_watcher(tx) {
|
||||
if watcher.watch(ctxt.root.clone(), RecursiveMode::Recursive).is_ok() {
|
||||
Some(Mutex::new((watcher, rx)))
|
||||
} else {
|
||||
warn!("Could not monitor the templates directory for changes.");
|
||||
warn_!("Live template reload will be unavailable");
|
||||
let watcher = match watcher {
|
||||
Ok(watcher) => Some(Mutex::new((watcher, rx))),
|
||||
Err(e) => {
|
||||
warn!("Failed to enable live template reloading: {}", e);
|
||||
debug_!("Reload error: {:?}", e);
|
||||
warn_!("Live template reloading is unavailable.");
|
||||
None
|
||||
}
|
||||
} else {
|
||||
warn!("Could not instantiate a filesystem watcher.");
|
||||
warn_!("Live template reload will be unavailable");
|
||||
None
|
||||
};
|
||||
|
||||
ContextManager {
|
||||
|
|
|
@ -157,6 +157,7 @@ mod templates_tests {
|
|||
// if the new content is correct, we are done
|
||||
let new_rendered = Template::show(client.rocket(), RELOAD_TEMPLATE, ());
|
||||
if new_rendered == Some(NEW_TEXT.into()) {
|
||||
write_file(&reload_path, INITIAL_TEXT);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue