This commit is contained in:
2024-07-19 05:15:09 +00:00
parent 82de40903b
commit 9d29487513
2 changed files with 8 additions and 16 deletions

View File

@@ -71,19 +71,13 @@ impl Config {
}
}
pub fn game_backuper_cfg(&self) -> String {
match self.get_str("game_backuper_cfg") {
Some(s) => {
pub fn game_backuper_cfg(&self) -> Option<String> {
let mut pb = crate::utils::get_exe_path_else_current();
pb.push(s);
pb.to_string_lossy().to_string()
},
None => {
let mut pb = crate::utils::get_exe_path_else_current();
pb.push("game_backuper.yml");
pb.to_string_lossy().to_string()
},
pb.push(self.get_str("game_backuper_cfg").unwrap_or("game_backuper.yml"));
if !pb.exists() {
return None;
}
Some(pb.to_string_lossy().to_string())
}
pub fn game_backuper_exe(&self) -> String {

View File

@@ -38,8 +38,7 @@ impl Main {
Some(cml) => cml,
None => {
let mut def = vec![self._cfg.game_backuper_exe()];
let cfg_path = self._cfg.game_backuper_cfg();
if std::fs::exists(&cfg_path).unwrap_or(false) {
if let Some(cfg_path) = self._cfg.game_backuper_cfg() {
def.push(String::from("-c"));
def.push(cfg_path);
}
@@ -74,8 +73,7 @@ impl Main {
Some(cml) => cml,
None => {
let mut def = vec![self._cfg.game_backuper_exe()];
let cfg_path = self._cfg.game_backuper_cfg();
if std::fs::exists(&cfg_path).unwrap_or(false) {
if let Some(cfg_path) = self._cfg.game_backuper_cfg() {
def.push(String::from("-c"));
def.push(cfg_path);
}