refactor: 优化部分代码,移除一批 unwrap

This commit is contained in:
amtoaer
2025-01-21 03:12:45 +08:00
parent c10c14c125
commit cdc30e1b32
9 changed files with 70 additions and 100 deletions

View File

@@ -46,11 +46,9 @@ fn load_config() -> Config {
}
warn!("配置文件不存在,使用默认配置...");
let default_config = Config::default();
if let Err(err) = default_config.save() {
panic!("保存默认配置时遇到错误: {err}");
}
info!("已将默认配置写入文件,请在修改后重新启动程序...");
std::process::exit(1);
default_config.save().expect("保存默认配置时遇到错误");
info!("已将默认配置写入 {}", CONFIG_DIR.join("config.toml").display());
default_config
});
// 检查配置文件内容
info!("校验配置文件内容...");

View File

@@ -136,7 +136,7 @@ impl Config {
}
if !(self.concurrent_limit.video > 0 && self.concurrent_limit.page > 0) {
ok = false;
error!("允许的并发数必须大于 0");
error!("video 和 page 允许的并发数必须大于 0");
}
if !ok {
panic!(