summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/config/mod.rs35
2 files changed, 25 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2bdd8c68..3d2a4e65 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Resolved off-by-one issue with erasing characters in the last column
- Excessive polling every 100ms with `live_config_reload` enabled
- Unicode characters at the beginning of URLs are now properly ignored
+- Remove error message when reloading an empty config
## Version 0.2.7
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 63c72d34..d9717704 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -2224,18 +2224,31 @@ impl Monitor {
loop {
match rx.recv().expect("watcher event") {
DebouncedEvent::Rename(_, _) => continue,
- DebouncedEvent::Write(path) | DebouncedEvent::Create(path)
- | DebouncedEvent::Chmod(path) => {
- // Reload file
- if path == config_path {
- match Config::load_from(path) {
- Ok(config) => {
- let _ = config_tx.send(config);
- handler.on_config_reload();
- },
- Err(err) => error!("Ignoring invalid config: {}", err),
+ DebouncedEvent::Write(path)
+ | DebouncedEvent::Create(path)
+ | DebouncedEvent::Chmod(path) =>
+ {
+ if path != config_path {
+ continue;
+ }
+
+ let config = match Config::load_from(&path) {
+ Ok(config) => {
+ config
+ },
+ Err(err) => {
+ if let Error::Empty = err {
+ info!("Config file {:?} is empty; loading default", path);
+ Config::default()
+ } else {
+ error!("Ignoring invalid config: {}", err);
+ continue;
+ }
}
- }
+ };
+
+ let _ = config_tx.send(config);
+ handler.on_config_reload();
}
_ => {}
}