aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/main.rs26
2 files changed, 15 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7b7ced9f..4c516a69 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Replaced `Command` with `Super` in the Linux and Windows config documentation
- Prevent semantic and line selection from starting with the right or middle mouse button
+- Prevent Alacritty from crashing when started on a system without any free space
## Version 0.2.5
diff --git a/src/main.rs b/src/main.rs
index 7c23616d..a5564cd2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -92,19 +92,21 @@ fn main() {
fn load_config(options: &cli::Options) -> Config {
let config_path = options.config_path()
.or_else(Config::installed_config)
- .unwrap_or_else(|| {
- Config::write_defaults()
- .unwrap_or_else(|err| die!("Write defaults config failure: {}", err))
- });
-
- Config::load_from(&*config_path).unwrap_or_else(|err| {
- match err {
- ConfigError::Empty => info!("Config file {:?} is empty; loading default", config_path),
- _ => error!("Error: {}; loading default config", err),
- }
-
+ .or_else(|| Config::write_defaults().ok());
+
+ if let Some(config_path) = config_path {
+ Config::load_from(&*config_path).unwrap_or_else(|err| {
+ match err {
+ ConfigError::Empty => info!("Config file {:?} is empty; loading default", config_path),
+ _ => error!("Unable to load default config: {}", err),
+ }
+
+ Config::default()
+ })
+ } else {
+ error!("Unable to write the default config");
Config::default()
- })
+ }
}
/// Run Alacritty