summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2019-01-09 20:27:13 +0000
committerGitHub <noreply@github.com>2019-01-09 20:27:13 +0000
commit8570ee004be5fb9d82e7d496662215c9b75c6334 (patch)
treed876a5dafce20250251b467616bf69f3f572bdd8 /src
parentc54115516717d6fd429065158d81a93c0818fefa (diff)
Fix crash when starting Alacritty on full drives
Since the Alacritty configuration file is written to the filesystem at startup, this could create issues when the system does not have any free space left. To circumvent this problem, the default configuration is now returned even when the configuration file could not be created. Instead of crashing Alacritty, an error is now emitted. Fixes #1936.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs26
1 files changed, 14 insertions, 12 deletions
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