add new option use-progress-bar

fix panic when artwork is 404
This commit is contained in:
2022-03-26 15:55:26 +08:00
parent 59f6923159
commit ad2e199b80
12 changed files with 329 additions and 104 deletions

View File

@@ -1,4 +1,6 @@
use crate::author_name_filter::check_author_name_filters;
use crate::ext::json::FromJson;
use crate::ext::use_or_not::UseOrNot;
use crate::gettext;
use crate::retry_interval::check_retry_interval;
use crate::settings::SettingDes;
@@ -17,6 +19,7 @@ pub fn get_settings_list() -> Vec<SettingDes> {
#[cfg(feature = "exif")]
SettingDes::new("update-exif", gettext("Add/Update exif information to image files even when overwrite are disabled."), JsonValueType::Boolean, None).unwrap(),
SettingDes::new("progress-bar-template", gettext("Progress bar's template. See <here> for more informations.").replace("<here>", "https://docs.rs/indicatif/latest/indicatif/#templates").as_str(), JsonValueType::Str, Some(check_nonempty_str)).unwrap(),
SettingDes::new("use-progress-bar", gettext("Whether to enable progress bar."), JsonValueType::Multiple, Some(check_user_or_not)).unwrap(),
]
}
@@ -29,3 +32,8 @@ fn check_nonempty_str(obj: &JsonValue) -> bool {
let r = obj.as_str();
r.is_some() && r.unwrap().len() != 0
}
fn check_user_or_not(obj: &JsonValue) -> bool {
let r = UseOrNot::from_json(obj);
r.is_ok()
}